aboutsummaryrefslogtreecommitdiff
path: root/2021/day4/reader.rkt
blob: b777f9293b0c2691824c9e2d38104cd3e38cb84e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)