turingAutomaton/reader.rkt
2020-03-31 09:35:50 +13:00

27 lines
775 B
Racket

#lang br/quicklang
(require "parser.rkt")
(define (read-syntax path port)
(define parse-tree (parse path (make-tokenizer port)))
(define module-datum `(module tA-mod turingAutomaton/expander
,parse-tree))
(datum->syntax #f module-datum))
(provide read-syntax)
(require brag/support)
(define-lex-abbrev digits (:+ (char-set "0123456789")))
(define (make-tokenizer port)
(define (next-token)
(define tA-lexer
(lexer
[(from/to ";" "\n") (next-token)]
[whitespace (next-token)]
["\n" (token 'NL lexeme)]
[(char-set "@%!~<>") lexeme]
[(:+ (:or digits alphabetic)) (token 'TA-STRING lexeme)]
[any-char lexeme]))
(tA-lexer port))
next-token)