diff options
Diffstat (limited to 'src/lexer-test.lisp')
-rw-r--r-- | src/lexer-test.lisp | 164 |
1 files changed, 82 insertions, 82 deletions
diff --git a/src/lexer-test.lisp b/src/lexer-test.lisp index cf3ba03..916af29 100644 --- a/src/lexer-test.lisp +++ b/src/lexer-test.lisp @@ -4,7 +4,7 @@ (loop :for token :in tokens :if (consp token) :collect (make-token (car token) (cadr token)) - :if (numberp token) + :if (typep token 'token-type) :collect (as-token token))) (defun test-lexer (str expect) @@ -14,15 +14,15 @@ (defun test-1 () (test-lexer "=+(){},;" - (make-tokens token-= - token-+ - token-lparen - token-rparen - token-lbrace - token-rbrace - token-comma - token-semicolon - token-eof))) + (make-tokens :t/= + :t/+ + :t/lparen + :t/rparen + :t/lbrace + :t/rbrace + :t/comma + :t/semicolon + :t/eof))) (defun test-2 () @@ -45,75 +45,75 @@ if (5 < 10) { 10 == 10; 10 != 9; " - (make-tokens token-let - (list token-ident "five") - token-= - (list token-int "5") - token-semicolon - token-let - (list token-ident "ten") - token-= - (list token-int "10") - token-semicolon - token-let - (list token-ident "add") - token-= - token-function - token-lparen - (list token-ident "x") - token-comma - (list token-ident "y") - token-rparen - token-lbrace - (list token-ident "x") - token-+ - (list token-ident "y") - token-rbrace - token-semicolon - token-let - (list token-ident "result") - token-= - (list token-ident "add") - token-lparen - (list token-ident "five") - token-comma - (list token-ident "ten") - token-rparen - token-semicolon - token-! - token-- - token-/ - token-* - token-semicolon - (list token-int "5") - token-< - (list token-int "10") - token-> - (list token-int "5") - token-semicolon - (list token-if "if") - token-lparen - (list token-int "5") - token-< - (list token-int "10") - token-rparen - token-lbrace - token-return - token-true - token-semicolon - token-rbrace - token-else - token-lbrace - token-return - token-false - token-semicolon - token-rbrace - (list token-int "10") - token-== - (list token-int "10") - token-semicolon - (list token-int "10") - token-!= - (list token-int "9") - token-semicolon - token-eof ""))) + (make-tokens :t/let + (list :t/ident "five") + :t/= + (list :t/int "5") + :t/semicolon + :t/let + (list :t/ident "ten") + :t/= + (list :t/int "10") + :t/semicolon + :t/let + (list :t/ident "add") + :t/= + :t/function + :t/lparen + (list :t/ident "x") + :t/comma + (list :t/ident "y") + :t/rparen + :t/lbrace + (list :t/ident "x") + :t/+ + (list :t/ident "y") + :t/rbrace + :t/semicolon + :t/let + (list :t/ident "result") + :t/= + (list :t/ident "add") + :t/lparen + (list :t/ident "five") + :t/comma + (list :t/ident "ten") + :t/rparen + :t/semicolon + :t/! + :t/- + :t// + :t/* + :t/semicolon + (list :t/int "5") + :t/< + (list :t/int "10") + :t/> + (list :t/int "5") + :t/semicolon + (list :t/if "if") + :t/lparen + (list :t/int "5") + :t/< + (list :t/int "10") + :t/rparen + :t/lbrace + :t/return + :t/true + :t/semicolon + :t/rbrace + :t/else + :t/lbrace + :t/return + :t/false + :t/semicolon + :t/rbrace + (list :t/int "10") + :t/== + (list :t/int "10") + :t/semicolon + (list :t/int "10") + :t/!= + (list :t/int "9") + :t/semicolon + :t/eof ""))) |