let <identifier> = <expression>;
[Type = "LET", Literal = "let"]
[Type = "IDENT", Literal = "hoge"]
[Type = "=", Literal = "="]
[Type = "INT", Literal = "1"]
[Type = "+", Literal = "+"]
[Type = "INT", Literal = "2"]
[Type = "*", Literal = "*"]
[Type = "INT", Literal = "3"]
[Type = "/", Literal = "/"]
[Type = "INT", Literal = "4"]
[Type = "+", Literal = "+"]
[Type = "INT", Literal = "5"]
[Type = "-", Literal = "-"]
[Type = "INT", Literal = "6"]
[Type = ";", Literal = ";"]
Token: {
Type: 'LET',
Literal: 'let'
},
Let: {
Token: {
Type: 'IDENT',
Literal: 'hoge'
},
IdentValue: 'hoge'
},
LetValue: {
Left: {
Left: {
Token: {
Type: 'INT',
Literal: '1'
},
IntValue: 1
},
Operator: '+',
Right: {
Left: {
Left: {
Token: {
Type: 'INT',
Literal: '2'
},
IntValue: 2
},
Operator: '*',
Right: {
Token: {
Type: 'INT',
Literal: '3'
},
IntValue: 3
}
},
Operator: '/',
Right: {
Token: {
Type: 'INT',
Literal: '4'
},
IntValue: 4
}
}
},
Operator: '+',
InRight: {
Left: {
Token: {
Type: 'INT',
Literal: '5'
},
IntValue: 5
},
Operator: '*',
Right: {
Token: {
Type: 'INT',
Literal: '6'
},
IntValue: 6
}
}
}
$ nim c -r src/repl/repl.nim
ref: Parsing - Wikipedia
2 * 3 / 4
Sum < Product # true
conditions
precedence < self.peekPrecedence()
not self.peekTokenIs(SEMICOLON)
ex.