pull/23/head
Matthew Butterick 5 years ago
parent 310651e374
commit 0a625a17ee

@ -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])

@ -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)

Loading…
Cancel
Save