about summary refs log tree commit diff
path: root/users/fcuny/exp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--users/fcuny/exp/monkey/pkg/lexer/lexer.go13
-rw-r--r--users/fcuny/exp/monkey/pkg/lexer/lexer_test.go19
2 files changed, 31 insertions, 1 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 ',':
diff --git a/users/fcuny/exp/monkey/pkg/lexer/lexer_test.go b/users/fcuny/exp/monkey/pkg/lexer/lexer_test.go
index 73b27fb..ba7fa07 100644
--- a/users/fcuny/exp/monkey/pkg/lexer/lexer_test.go
+++ b/users/fcuny/exp/monkey/pkg/lexer/lexer_test.go
@@ -44,7 +44,10 @@ let add = fn(x, y) {
   x + y
 };
 
-let result = add(five, ten);`
+let result = add(five, ten);
+!-/*5;
+5 < 10 > 5;
+`
 
 	tests := []struct {
 		expectedType    token.TokenType
@@ -88,6 +91,20 @@ let result = add(five, ten);`
 		{token.IDENT, "ten"},
 		{token.RPAREN, ")"},
 		{token.SEMICOLON, ";"},
+
+		{token.BANG, "!"},
+		{token.MINUS, "-"},
+		{token.SLASH, "/"},
+		{token.ASTERISK, "*"},
+		{token.INT, "5"},
+		{token.SEMICOLON, ";"},
+
+		{token.INT, "5"},
+		{token.LT, "<"},
+		{token.INT, "10"},
+		{token.GT, ">"},
+		{token.INT, "5"},
+		{token.SEMICOLON, ";"},
 	}
 
 	l := New(input)