From 1d70a700c9ec610a4d7cbfa5e59c878b9b4dd5da Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 2 Feb 2025 21:31:56 +0100 Subject: [PATCH] begin variables --- lexer/lexer.go | 2 ++ test.tt | 13 +++++++++---- token/token.go | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lexer/lexer.go b/lexer/lexer.go index d405a45..194580d 100644 --- a/lexer/lexer.go +++ b/lexer/lexer.go @@ -65,6 +65,8 @@ func (l *Lexer) NextToken() token.Token { switch l.ch { case ';': tok = l.newToken(token.Semicolon) + case ':': + tok = l.newToken(token.Colon) case '=': if l.peekByte() == '=' { pos := l.position diff --git a/test.tt b/test.tt index ec647d0..486e533 100644 --- a/test.tt +++ b/test.tt @@ -1,6 +1,11 @@ fn main() = { - if 3 == 2 { - if 3 == 3 in 3 - else 4 - } else 2 + hi: i64 = 4; + + if hi == 2 { + hi = 3 + } else { + hi = 2 + } + + hi }; diff --git a/token/token.go b/token/token.go index a09aaf5..111638a 100644 --- a/token/token.go +++ b/token/token.go @@ -32,6 +32,7 @@ const ( Int TokenType = "INT" Semicolon TokenType = ";" + Colon TokenType = ":" Equal TokenType = "=" OpenParen TokenType = "(" CloseParen TokenType = ")"