zybino/old-code/lexer.rkt

19 lines
530 B
Racket
Raw Normal View History

2020-06-08 22:50:42 -04:00
#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)