You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
beautiful-racket/beautiful-racket-demo/hdl-tst-demo/main.rkt

23 lines
737 B
Racket

#lang br
(require "grammar.rkt" brag/support)
(module+ reader
(provide read-syntax))
(define tokenize
(lexer-srcloc
[(:or (from/to "/*" "*/")
(from/to "//" #\newline)) (token 'COMMENT lexeme #:skip? #t)]
[whitespace (token lexeme #:skip? #t)]
[(:or "load" "output-list" "output-file" "compare-to" "set" "eval" "output" "," ";") lexeme]
[(:seq "%" (:+ alphabetic numeric ".")) (token 'FORMAT-STRING lexeme)]
[(:+ numeric) (token 'VAL (string->number lexeme))]
[(:+ alphabetic numeric "-" ".") (token 'ID lexeme)]))
(define (read-syntax src ip)
(port-count-lines! ip)
(strip-context
(with-syntax ([PT (parse src (λ () (tokenize ip)))])
#'(module hdl-mod hdl-tst-demo/expander
PT))))