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
|
||||
.direnv
|
||||
|
@ -40,7 +40,7 @@ func NewSourceProgram(inputFile string, outputFile string) *SourceProgram {
|
||||
}
|
||||
|
||||
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)
|
||||
rootNodes := []int{}
|
||||
|
@ -110,6 +110,12 @@ func (l *Lexer) NextToken() token.Token {
|
||||
case '*':
|
||||
tok = l.newToken(token.Asterisk)
|
||||
case '/':
|
||||
if l.peekByte() == '/' {
|
||||
for l.ch != '\n' {
|
||||
l.readChar()
|
||||
}
|
||||
return l.NextToken()
|
||||
}
|
||||
tok = l.newToken(token.Slash)
|
||||
case '{':
|
||||
tok = l.newToken(token.OpenBrack)
|
||||
|
7
test.tt
7
test.tt
@ -8,10 +8,7 @@ fn main() = {
|
||||
}
|
||||
};
|
||||
|
||||
fn test2(hello: i32,) = {
|
||||
hello
|
||||
fn test2(hello: i64,) = {
|
||||
hello // Comment test
|
||||
};
|
||||
|
||||
fn test2(hello: i32,) = {
|
||||
hello
|
||||
};
|
||||
|
@ -22,6 +22,7 @@ func (p *Program) String() string {
|
||||
|
||||
type Function struct {
|
||||
Name string
|
||||
Arguments []string
|
||||
Instructions []Instruction
|
||||
HasReturnValue bool
|
||||
}
|
||||
|
@ -79,8 +79,9 @@ func VarResolve(p *ast.Program) (map[string]Scope, error) {
|
||||
}
|
||||
|
||||
s := Scope{Variables: make(map[string]Var)}
|
||||
for _, arg := range d.Args {
|
||||
s.SetUniq(arg.Name)
|
||||
for i, arg := range d.Args {
|
||||
uniq := s.SetUniq(arg.Name)
|
||||
d.Args[i].Name = uniq
|
||||
}
|
||||
err := VarResolveExpr(&s, d.Body)
|
||||
functionToScope[d.Name] = s
|
||||
|
Loading…
x
Reference in New Issue
Block a user