|
|
@ -5,6 +5,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
(define-lex-abbrev reserved-terms (:or "print" "goto" "end" "+" ":" ";" "let" "=" "input" "-" "*" "/" "^" "mod" "(" ")" "def" "if" "then" "else" "<" ">" "<>" "and" "or" "not" "gosub" "return" "for" "to" "step" "next" "def" "," "import"))
|
|
|
|
(define-lex-abbrev reserved-terms (:or "print" "goto" "end" "+" ":" ";" "let" "=" "input" "-" "*" "/" "^" "mod" "(" ")" "def" "if" "then" "else" "<" ">" "<>" "and" "or" "not" "gosub" "return" "for" "to" "step" "next" "def" "," "import"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-lex-abbrev id-kapu
|
|
|
|
|
|
|
|
(:or whitespace (char-set "()[]{}\",'`;#|\\")))
|
|
|
|
|
|
|
|
|
|
|
|
(define basic-lexer
|
|
|
|
(define basic-lexer
|
|
|
|
(lexer-srcloc
|
|
|
|
(lexer-srcloc
|
|
|
|
[(eof) (return-without-srcloc eof)]
|
|
|
|
[(eof) (return-without-srcloc eof)]
|
|
|
@ -12,12 +15,11 @@
|
|
|
|
[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)]
|
|
|
|
[reserved-terms (token lexeme lexeme)]
|
|
|
|
[reserved-terms (token lexeme lexeme)]
|
|
|
|
[(:seq alphabetic (:* (:or alphabetic numeric "$" "/" "-" "?")))
|
|
|
|
|
|
|
|
(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 "."))
|
|
|
|
(token 'DECIMAL (string->number lexeme))]
|
|
|
|
(token 'DECIMAL (string->number lexeme))]
|
|
|
|
|
|
|
|
[(:+ (:~ id-kapu)) (token 'ID (string->symbol lexeme))]
|
|
|
|
[(:or (from/to "\"" "\"") (from/to "'" "'"))
|
|
|
|
[(:or (from/to "\"" "\"") (from/to "'" "'"))
|
|
|
|
(token 'STRING
|
|
|
|
(token 'STRING
|
|
|
|
(substring lexeme
|
|
|
|
(substring lexeme
|
|
|
|