aboutsummaryrefslogtreecommitdiff
path: root/2021/day4/reader.rkt
diff options
context:
space:
mode:
authorAria <me@aria.rip>2023-01-02 21:58:56 +0000
committerAria <me@aria.rip>2023-01-02 21:58:56 +0000
commit5eb58ad076f2cd435b11b140820da224b60b73d5 (patch)
tree2a67939595fbf993ff04f69b9cd3f0aa20827d96 /2021/day4/reader.rkt
initial commit
Diffstat (limited to '2021/day4/reader.rkt')
-rw-r--r--2021/day4/reader.rkt21
1 files changed, 21 insertions, 0 deletions
diff --git a/2021/day4/reader.rkt b/2021/day4/reader.rkt
new file mode 100644
index 0000000..b777f92
--- /dev/null
+++ b/2021/day4/reader.rkt
@@ -0,0 +1,21 @@
+#lang racket
+
+(require "parser.rkt")
+(require brag/support)
+
+(define (make-tokenizer port)
+ (define (next-token)
+ (define bf-lexer
+ (lexer
+ [(char-set "\n1234567890, ") lexeme]
+ [any-char (next-token)]))
+ (bf-lexer port))
+ next-token)
+
+(define (read-syntax path port)
+ (define parse-tree (parse path (make-tokenizer port)))
+ (define module-datum `(module day4 racket
+ ,parse-tree))
+ (datum->syntax #f module-datum))
+
+(provide read-syntax)