-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtokenizer.rkt
More file actions
16 lines (14 loc) · 810 Bytes
/
Copy pathtokenizer.rkt
File metadata and controls
16 lines (14 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#lang br
(require "lexer.rkt" brag/support)
; The tokenizer is an important part of the reader, it consumes characters from an input port (like a source file)
; and using a lexer, it groups those characters into tokens that the parser can use to build the parse tree.
; The tokenizer and the underlying lexer filter out all the patterns of characters that are not relevant to the language
; so that the parser can focus better on its job.
; The parser expects the tokenizer to provide a make-tokenizer function which returns a next-token function
; which can be used by the parser to get the next token to parse from the input port.
(define (make-tokenizer iport [path #f])
(port-count-lines! iport)
(lexer-file-path path)
(define (next-token) (secd-lexer iport))
next-token)
(provide make-tokenizer)