begin variables

This commit is contained in:
Robin 2025-02-02 21:31:56 +01:00
parent 0692729b40
commit 1d70a700c9
3 changed files with 12 additions and 4 deletions

View File

@ -65,6 +65,8 @@ func (l *Lexer) NextToken() token.Token {
switch l.ch { switch l.ch {
case ';': case ';':
tok = l.newToken(token.Semicolon) tok = l.newToken(token.Semicolon)
case ':':
tok = l.newToken(token.Colon)
case '=': case '=':
if l.peekByte() == '=' { if l.peekByte() == '=' {
pos := l.position pos := l.position

13
test.tt
View File

@ -1,6 +1,11 @@
fn main() = { fn main() = {
if 3 == 2 { hi: i64 = 4;
if 3 == 3 in 3
else 4 if hi == 2 {
} else 2 hi = 3
} else {
hi = 2
}
hi
}; };

View File

@ -32,6 +32,7 @@ const (
Int TokenType = "INT" Int TokenType = "INT"
Semicolon TokenType = ";" Semicolon TokenType = ";"
Colon TokenType = ":"
Equal TokenType = "=" Equal TokenType = "="
OpenParen TokenType = "(" OpenParen TokenType = "("
CloseParen TokenType = ")" CloseParen TokenType = ")"