updates
parent
87009e367b
commit
f25679622a
@ -1,23 +1,13 @@
|
||||
#lang brag
|
||||
|
||||
tst-program : load-expr output-file-expr compare-to-expr output-list-expr /";" test-expr*
|
||||
|
||||
load-expr : /"load" ID /","
|
||||
|
||||
output-file-expr : /"output-file" ID /","
|
||||
|
||||
compare-to-expr : /"compare-to" ID /","
|
||||
|
||||
output-list-expr : /"output-list" column [column]+
|
||||
|
||||
/column : ID FORMAT-STRING
|
||||
|
||||
@test-expr : step-expr+ /";"
|
||||
|
||||
@step-expr : (set-expr | eval-expr | output-expr) [/","]
|
||||
|
||||
set-expr : /"set" ID VAL
|
||||
|
||||
eval-expr : /"eval"
|
||||
|
||||
output-expr : /"output"
|
||||
tst-program : tst-load-expr tst-output-file-expr tst-compare-to-expr tst-output-list-expr /";" tst-test-expr*
|
||||
tst-load-expr : /"load" ID /","
|
||||
tst-output-file-expr : /"output-file" ID /","
|
||||
tst-compare-to-expr : /"compare-to" ID /","
|
||||
tst-output-list-expr : /"output-list" tst-column [tst-column]+
|
||||
/tst-column : ID FORMAT-STRING
|
||||
@tst-test-expr : tst-step-expr+ /";"
|
||||
@tst-step-expr : (tst-set-expr | tst-eval-expr | tst-output-expr) [/","]
|
||||
tst-set-expr : /"set" ID VAL
|
||||
tst-eval-expr : /"eval"
|
||||
tst-output-expr : /"output"
|
@ -1,21 +1,18 @@
|
||||
#lang br
|
||||
(require brag/support
|
||||
racket/string)
|
||||
#lang br/quicklang
|
||||
(require brag/support)
|
||||
(provide make-tokenizer)
|
||||
|
||||
(provide tokenize)
|
||||
(define (tokenize input-port)
|
||||
(define (next-token)
|
||||
(define get-token
|
||||
(lexer-src-pos
|
||||
[(eof) eof]
|
||||
[(union
|
||||
(:seq "/*" (complement (:seq any-string "*/" any-string)) "*/")
|
||||
(:seq "//" (repetition 1 +inf.0 (char-complement #\newline)) #\newline))
|
||||
(token 'COMMENT lexeme #:skip? #t)]
|
||||
[(union #\tab #\space #\newline) (return-without-pos (get-token input-port))]
|
||||
[(union "load" "output-list" "output-file" "compare-to" "set" "eval" "output" (char-set ",;")) lexeme]
|
||||
[(:seq "%" (repetition 1 +inf.0 (union alphabetic numeric (char-set ".")))) (token 'FORMAT-STRING lexeme)]
|
||||
[(repetition 1 +inf.0 numeric) (token 'VAL (string->number lexeme))]
|
||||
[(repetition 1 +inf.0 (union alphabetic numeric (char-set "-."))) (token 'ID lexeme)]))
|
||||
(get-token input-port))
|
||||
(define hdl-test-lexer
|
||||
(lexer-srcloc
|
||||
[(eof) eof]
|
||||
[(: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 (make-tokenizer ip)
|
||||
(define (next-token) (hdl-test-lexer ip))
|
||||
next-token)
|
||||
|
Loading…
Reference in New Issue