diff --git a/beautiful-racket-demo/precalc-demo/main.rkt b/beautiful-racket-demo/precalc-demo/main.rkt index 581392b..caeb866 100644 --- a/beautiful-racket-demo/precalc-demo/main.rkt +++ b/beautiful-racket-demo/precalc-demo/main.rkt @@ -11,14 +11,13 @@ (define-lex-abbrev digits (char-set "0123456789")) (define tokenize-1 - (lexer-srcloc + (lexer [whitespace (token lexeme #:skip? #t)] [(:or (from/stop-before "#" "\n") (from/to "/*" "*/")) (token 'COMMENT #:skip? #t)] [reserved-toks lexeme] [(:seq (:? "-") (:+ digits)) (token 'INT (string->number lexeme))] - [(:+ (:- (:or alphabetic digits) reserved-toks)) - (token 'ID (string->symbol lexeme))])) + [(:+ alphabetic) (token 'ID (string->symbol lexeme))])) (define-macro top #'#%module-begin) @@ -38,8 +37,6 @@ (define-macro app #'#%app) (define (read-syntax src ip) - (port-count-lines! ip) - (lexer-file-path src) (define parse-tree (parse src (λ () (tokenize-1 ip)))) (strip-bindings (with-syntax ([PT parse-tree]) diff --git a/beautiful-racket-demo/precalc-demo/test.rkt b/beautiful-racket-demo/precalc-demo/test.rkt index 9db0535..84baf46 100644 --- a/beautiful-racket-demo/precalc-demo/test.rkt +++ b/beautiful-racket-demo/precalc-demo/test.rkt @@ -1,10 +1,10 @@ #lang precalc-demo fun f(x, y, z) = x + x + x * (y + y) + y * z - z - z -fun g42(z) = f(z, z, z) # line comment -g42(-10) # = 300 +fun g(z) = f(z, z, z) # line comment +g(-10) # = 300 -fun h() = g42(10) +fun h() = g(10) h() # = 300 fun k(x) = x / 10 / 10 / (x / x)