|
|
@ -11,14 +11,13 @@
|
|
|
|
(define-lex-abbrev digits (char-set "0123456789"))
|
|
|
|
(define-lex-abbrev digits (char-set "0123456789"))
|
|
|
|
|
|
|
|
|
|
|
|
(define tokenize-1
|
|
|
|
(define tokenize-1
|
|
|
|
(lexer-srcloc
|
|
|
|
(lexer
|
|
|
|
[whitespace (token lexeme #:skip? #t)]
|
|
|
|
[whitespace (token lexeme #:skip? #t)]
|
|
|
|
[(:or (from/stop-before "#" "\n")
|
|
|
|
[(:or (from/stop-before "#" "\n")
|
|
|
|
(from/to "/*" "*/")) (token 'COMMENT #:skip? #t)]
|
|
|
|
(from/to "/*" "*/")) (token 'COMMENT #:skip? #t)]
|
|
|
|
[reserved-toks lexeme]
|
|
|
|
[reserved-toks lexeme]
|
|
|
|
[(:seq (:? "-") (:+ digits)) (token 'INT (string->number lexeme))]
|
|
|
|
[(:seq (:? "-") (:+ digits)) (token 'INT (string->number lexeme))]
|
|
|
|
[(:+ (:- (:or alphabetic digits) reserved-toks))
|
|
|
|
[(:+ alphabetic) (token 'ID (string->symbol lexeme))]))
|
|
|
|
(token 'ID (string->symbol lexeme))]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-macro top #'#%module-begin)
|
|
|
|
(define-macro top #'#%module-begin)
|
|
|
|
|
|
|
|
|
|
|
@ -38,8 +37,6 @@
|
|
|
|
(define-macro app #'#%app)
|
|
|
|
(define-macro app #'#%app)
|
|
|
|
|
|
|
|
|
|
|
|
(define (read-syntax src ip)
|
|
|
|
(define (read-syntax src ip)
|
|
|
|
(port-count-lines! ip)
|
|
|
|
|
|
|
|
(lexer-file-path src)
|
|
|
|
|
|
|
|
(define parse-tree (parse src (λ () (tokenize-1 ip))))
|
|
|
|
(define parse-tree (parse src (λ () (tokenize-1 ip))))
|
|
|
|
(strip-bindings
|
|
|
|
(strip-bindings
|
|
|
|
(with-syntax ([PT parse-tree])
|
|
|
|
(with-syntax ([PT parse-tree])
|
|
|
|