diff options
author | franck cuny <franck@fcuny.net> | 2020-01-11 13:53:44 +0100 |
---|---|---|
committer | franck cuny <franck@fcuny.net> | 2020-01-11 14:17:34 +0100 |
commit | bcd7ed3ec9f59f350a29eb95ffbac71345d93e6d (patch) | |
tree | 361bafc159a9716fb28f0f7cd6cff56b985f4590 /users/fcuny/exp/monkey/pkg/lexer/lexer.go | |
parent | token: support more operator tokens (diff) | |
download | world-bcd7ed3ec9f59f350a29eb95ffbac71345d93e6d.tar.gz |
lexer: support more operator tokens.
Support the operator tokens that were added to our tokenizer. This also add a few more tests to ensure we handle them correctly.
Diffstat (limited to '')
-rw-r--r-- | users/fcuny/exp/monkey/pkg/lexer/lexer.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/users/fcuny/exp/monkey/pkg/lexer/lexer.go b/users/fcuny/exp/monkey/pkg/lexer/lexer.go index fc29371..d538cf5 100644 --- a/users/fcuny/exp/monkey/pkg/lexer/lexer.go +++ b/users/fcuny/exp/monkey/pkg/lexer/lexer.go @@ -67,6 +67,19 @@ func (l *Lexer) NextToken() token.Token { 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.ASTERISK, l.ch) + case '/': + tok = newToken(token.SLASH, l.ch) + case '<': + tok = newToken(token.LT, l.ch) + case '>': + tok = newToken(token.GT, l.ch) + case ';': tok = newToken(token.SEMICOLON, l.ch) case ',': |