|
|
@ -3,8 +3,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
(define-lex-abbrev digits (:+ (char-set "0123456789")))
|
|
|
|
(define-lex-abbrev digits (:+ (char-set "0123456789")))
|
|
|
|
|
|
|
|
|
|
|
|
(define (handle-tok-error tok-ok? tok-name tok-value start-pos end-pos)
|
|
|
|
(define-lex-abbrev reserved-terms (:or "print" "goto" "end" "+" ":" "let" "=" "gosub" "return" "-" "for" "to" "step" "next" "if" "then" "else" "and" "or" "<" ">" "*" "/" "(" ")" "^" "!" "%" "input" ";" "def"))
|
|
|
|
(token 'ERROR tok-value))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define basic-lexer
|
|
|
|
(define basic-lexer
|
|
|
|
(lexer-srcloc
|
|
|
|
(lexer-srcloc
|
|
|
@ -12,9 +11,9 @@
|
|
|
|
["\n" (token 'NEWLINE lexeme)]
|
|
|
|
["\n" (token 'NEWLINE lexeme)]
|
|
|
|
[whitespace (token lexeme #:skip? #t)]
|
|
|
|
[whitespace (token lexeme #:skip? #t)]
|
|
|
|
[(from/stop-before "rem" "\n") (token 'REM lexeme)]
|
|
|
|
[(from/stop-before "rem" "\n") (token 'REM lexeme)]
|
|
|
|
[(:or "print" "goto" "end" "+" ":" "gosub" "return" "let" "=" "-" "for" "to" "step" "next"
|
|
|
|
[reserved-terms (token lexeme lexeme)]
|
|
|
|
"if" "then" "else" "and" "or" "<" ">" "*" "/" "(" ")" "^" "!" "%" "input" ";" "def") (token lexeme lexeme)]
|
|
|
|
[(:seq alphabetic (:* (:or alphabetic numeric "$")))
|
|
|
|
[(:seq (:+ alphabetic) (:* (:or alphabetic numeric "$"))) (token 'ID (string->symbol lexeme))]
|
|
|
|
(token 'ID (string->symbol lexeme))]
|
|
|
|
[digits (token 'INTEGER (string->number lexeme))]
|
|
|
|
[digits (token 'INTEGER (string->number lexeme))]
|
|
|
|
[(:or (:seq (:? digits) "." digits)
|
|
|
|
[(:or (:seq (:? digits) "." digits)
|
|
|
|
(:seq digits "."))
|
|
|
|
(:seq digits "."))
|
|
|
|