zybino/old-code/lexer.rkt
2020-06-09 14:50:42 +12:00

19 lines
530 B
Racket

#lang br
(require brag/support)
(define-lex-abbrev digits (:+ (char-set "0123456789")))
(define-lex-abbrev reserved-terms (:or "LD" ","))
(define-lex-abbrev register-terms (:or "A" "B" "C" "D" "E" "F" "H" "L"))
(define basic-lexer
(lexer-srcloc
["\n" (token 'NEWLINE lexeme)]
[whitespace (token lexeme #:skip? #t)]
[reserved-terms (token lexeme lexeme)]
[register-terms (token 'REGISTER-ID (string->symbol lexeme))]
[digits (token 'U8-NUMBER (string->number lexeme))]))
(provide basic-lexer)