mirror of
https://github.com/RoBaertschi/tt.git
synced 2025-04-15 21:43:30 +00:00
direnv and some arg fixes
This commit is contained in:
parent
45dad474e0
commit
b633246af8
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
result
|
result
|
||||||
|
.direnv
|
||||||
|
@ -40,7 +40,7 @@ func NewSourceProgram(inputFile string, outputFile string) *SourceProgram {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sp *SourceProgram) Build(backend asm.Backend, emitAsmOnly bool, toPrint ToPrintFlags) error {
|
func (sp *SourceProgram) Build(backend asm.Backend, emitAsmOnly bool, toPrint ToPrintFlags) error {
|
||||||
l := utils.NewLogger(os.Stderr, "[build] ", utils.Info)
|
l := utils.NewLogger(os.Stderr, "[build] ", utils.Debug)
|
||||||
|
|
||||||
nodes := make(map[int]*node)
|
nodes := make(map[int]*node)
|
||||||
rootNodes := []int{}
|
rootNodes := []int{}
|
||||||
|
@ -110,6 +110,12 @@ func (l *Lexer) NextToken() token.Token {
|
|||||||
case '*':
|
case '*':
|
||||||
tok = l.newToken(token.Asterisk)
|
tok = l.newToken(token.Asterisk)
|
||||||
case '/':
|
case '/':
|
||||||
|
if l.peekByte() == '/' {
|
||||||
|
for l.ch != '\n' {
|
||||||
|
l.readChar()
|
||||||
|
}
|
||||||
|
return l.NextToken()
|
||||||
|
}
|
||||||
tok = l.newToken(token.Slash)
|
tok = l.newToken(token.Slash)
|
||||||
case '{':
|
case '{':
|
||||||
tok = l.newToken(token.OpenBrack)
|
tok = l.newToken(token.OpenBrack)
|
||||||
|
7
test.tt
7
test.tt
@ -8,10 +8,7 @@ fn main() = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fn test2(hello: i32,) = {
|
fn test2(hello: i64,) = {
|
||||||
hello
|
hello // Comment test
|
||||||
};
|
};
|
||||||
|
|
||||||
fn test2(hello: i32,) = {
|
|
||||||
hello
|
|
||||||
};
|
|
||||||
|
@ -22,6 +22,7 @@ func (p *Program) String() string {
|
|||||||
|
|
||||||
type Function struct {
|
type Function struct {
|
||||||
Name string
|
Name string
|
||||||
|
Arguments []string
|
||||||
Instructions []Instruction
|
Instructions []Instruction
|
||||||
HasReturnValue bool
|
HasReturnValue bool
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,9 @@ func VarResolve(p *ast.Program) (map[string]Scope, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s := Scope{Variables: make(map[string]Var)}
|
s := Scope{Variables: make(map[string]Var)}
|
||||||
for _, arg := range d.Args {
|
for i, arg := range d.Args {
|
||||||
s.SetUniq(arg.Name)
|
uniq := s.SetUniq(arg.Name)
|
||||||
|
d.Args[i].Name = uniq
|
||||||
}
|
}
|
||||||
err := VarResolveExpr(&s, d.Body)
|
err := VarResolveExpr(&s, d.Body)
|
||||||
functionToScope[d.Name] = s
|
functionToScope[d.Name] = s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user