Mercurial > hg > Members > anatofuz > monkey
changeset 2:595b3e2dc94e
impl symbol lexer
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 15 May 2020 10:26:01 +0900 (2020-05-15) |
parents | a1166907ac2d |
children | 6bd28d00a4f4 |
files | lexer/lexer.go lexer/lexer_test.go |
diffstat | 2 files changed, 17 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/lexer/lexer.go Fri May 15 10:20:57 2020 +0900 +++ b/lexer/lexer.go Fri May 15 10:26:01 2020 +0900 @@ -37,16 +37,28 @@ switch l.ch { case '=': tok = newToken(token.ASSIGN, l.ch) + case '+': + tok = newToken(token.PLUS, l.ch) + case '-': + tok = newToken(token.MINUS, l.ch) + case '!': + tok = newToken(token.BANG, l.ch) + case '/': + tok = newToken(token.SLASH, l.ch) + case '*': + tok = newToken(token.ASTERISK, l.ch) + case '<': + tok = newToken(token.LT, l.ch) + case '>': + tok = newToken(token.GT, l.ch) case ';': tok = newToken(token.SEMICOLON, l.ch) + case ',': + tok = newToken(token.COMMA, l.ch) case '(': tok = newToken(token.LPAREN, l.ch) case ')': tok = newToken(token.RPAREN, l.ch) - case ',': - tok = newToken(token.COMMA, l.ch) - case '+': - tok = newToken(token.PLUS, l.ch) case '{': tok = newToken(token.LBRACE, l.ch) case '}':