|
|
|
@ -8,10 +8,10 @@
|
|
|
|
|
(define-lex-abbrev reserved-toks
|
|
|
|
|
(:or "fun" "(" ")" "=" "+" "*" "/" "-" ","))
|
|
|
|
|
|
|
|
|
|
(define lex
|
|
|
|
|
(define tokenize
|
|
|
|
|
(lexer
|
|
|
|
|
[(:or (from/to "//" "\n") (from/to "/*" "*/")) (token 'COMMENT #:skip? #t)]
|
|
|
|
|
[whitespace (lex input-port)]
|
|
|
|
|
[whitespace (tokenize input-port)]
|
|
|
|
|
[reserved-toks lexeme]
|
|
|
|
|
[alphabetic (token 'ID (string->symbol lexeme))]
|
|
|
|
|
[(:+ (char-set "0123456789")) (token 'INT (string->number lexeme))]))
|
|
|
|
@ -35,8 +35,7 @@
|
|
|
|
|
(define-macro func-app #'#%app)
|
|
|
|
|
|
|
|
|
|
(define (read-syntax src ip)
|
|
|
|
|
(define token-thunk (λ () (lex ip)))
|
|
|
|
|
(define parse-tree (parse token-thunk))
|
|
|
|
|
(define parse-tree (parse (λ () (tokenize ip))))
|
|
|
|
|
(strip-context
|
|
|
|
|
(with-syntax ([PT parse-tree])
|
|
|
|
|
#'(module mod-name precalc-demo
|
|
|
|
|