@@ -34,6 +34,15 @@ func advance(l: Lexer) -> void:
3434end
3535
3636
37+ func match_next(l: Lexer, expected: char) -> bool:
38+ if l.at_end() or l.peek()? != expected:
39+ return false
40+ end
41+ l.advance()
42+ return true
43+ end
44+
45+
3746func is_whitespace(ch: char) -> bool:
3847 return ch == ' ' or ch == '\t' or ch == '\r'
3948end
@@ -132,6 +141,12 @@ func next_token(l: Lexer, r: Region) -> token::Token:
132141 elif ch == '=':
133142 l.advance()
134143 return token::Token{type = token::TokenType.ASSIGN, span = l.span(start, l.pos, r)}[r]
144+ elif ch == ':':
145+ l.advance()
146+ if l.match_next('='):
147+ return token::Token{type = token::TokenType.DECLARE, span = l.span(start, l.pos, r)}[r]
148+ end
149+ return token::Token{type = token::TokenType.COLON, span = l.span(start, l.pos, r)}[r]
135150 elif ch == '(':
136151 l.advance()
137152 return token::Token{type = token::TokenType.LPAREN, span = l.span(start, l.pos, r)}[r]
@@ -141,9 +156,9 @@ func next_token(l: Lexer, r: Region) -> token::Token:
141156 elif ch == ',':
142157 l.advance()
143158 return token::Token{type = token::TokenType.COMMA, span = l.span(start, l.pos, r)}[r]
144- elif ch == ': ':
159+ elif ch == '+ ':
145160 l.advance()
146- return token::Token{type = token::TokenType.COLON , span = l.span(start, l.pos, r)}[r]
161+ return token::Token{type = token::TokenType.OP_PLUS , span = l.span(start, l.pos, r)}[r]
147162 elif ch == '"':
148163 return l.scan_string(r)
149164 elif char::isdigit(ch):
0 commit comments