# HG changeset patch # User anatofuz # Date 1589505657 -32400 # Node ID a1166907ac2d4be8b0aacfff89177305dd80d86a # Parent 72d22ea567955193060508aec278a8acefdebcb8 add calc test diff -r 72d22ea56795 -r a1166907ac2d lexer/lexer_test.go --- a/lexer/lexer_test.go Fri May 15 10:12:16 2020 +0900 +++ b/lexer/lexer_test.go Fri May 15 10:20:57 2020 +0900 @@ -14,6 +14,8 @@ }; let result = add(five, ten); + !-/*5; + 5 < 10 > 5; ` tests := []struct { @@ -36,6 +38,38 @@ {token.FUNCTION, "fn"}, {token.LPAREN, "("}, {token.IDENT, "x"}, + {token.COMMA, ","}, + {token.IDENT, "y"}, + {token.RPAREN, ")"}, + {token.LBRACE, "{"}, + {token.IDENT, "x"}, + {token.PLUS, "+"}, + {token.IDENT, "y"}, + {token.SEMICOLON, ";"}, + {token.RBRACE, "}"}, + {token.SEMICOLON, ";"}, + {token.LET, "let"}, + {token.IDENT, "result"}, + {token.ASSIGN, "="}, + {token.IDENT, "add"}, + {token.LPAREN, "("}, + {token.IDENT, "five"}, + {token.COMMA, ","}, + {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.SEMICOLON, ";"}, + {token.EOF, ""}, } l := New(input) diff -r 72d22ea56795 -r a1166907ac2d token/token.go --- a/token/token.go Fri May 15 10:12:16 2020 +0900 +++ b/token/token.go Fri May 15 10:20:57 2020 +0900 @@ -10,6 +10,14 @@ ASSIGN = "=" PLUS = "+" + MINUS = "-" + BANG = "!" + ASTERISK = "*" + SLASH = "/" + + LT = "<" + GT = ">" + COMMA = "," SEMICOLON = ";"