|
|
|
@ -1,11 +1,11 @@
|
|
|
|
|
#lang br
|
|
|
|
|
(require brag/support racket/contract)
|
|
|
|
|
(require brag/support)
|
|
|
|
|
|
|
|
|
|
(define basic-lexer
|
|
|
|
|
(lexer-srcloc
|
|
|
|
|
[(eof) (return-without-srcloc eof)]
|
|
|
|
|
[whitespace (token lexeme #:skip? #t)]
|
|
|
|
|
[(from/to "rem" "\n") (token 'REM lexeme)]
|
|
|
|
|
[(from/to "rem" #\newline) (token 'REM lexeme)]
|
|
|
|
|
[(:or "print" "goto" "end" "+" ":") lexeme]
|
|
|
|
|
[(:+ numeric) (token 'INTEGER (string->number lexeme))]
|
|
|
|
|
[(:or (:seq (:+ numeric) ".")
|
|
|
|
@ -15,10 +15,3 @@
|
|
|
|
|
(token 'STRING (trim-ends "\"" lexeme "\""))]))
|
|
|
|
|
|
|
|
|
|
(provide basic-lexer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (apply-lexer lexer str)
|
|
|
|
|
(for/list ([t (in-port lexer (open-input-string str))])
|
|
|
|
|
t))
|
|
|
|
|
|
|
|
|
|
(apply-lexer basic-lexer "10 rem")
|
|
|
|
|