blob: 0661fa693c896952dc719a7c8389c336aef6317d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
(define-module (modules lexer lexer)
#:export (read-tokens-from-port))
(define (read-tokens-from-port port)
""
(display (read-char port)))
(define (read-token)
(define (read-token-loop first-char)
(cond
((or (char-whitespace? first-char))
(read-token)
((eq? first-char #\()
(cons 'left-paren #\())
((eq? first-char #\))
(cons 'right-paren #\)))
((eq? first-char #\{)
(cons 'right-bracket #\{))
((eq? first-char #\})
(cons 'right-bracket #\}))
(#t
(error "illegal lexical syntax")))))
(let ((first-char (read-char)))
(if (eof-object? first-char)
'()
(cons (read-token-loop first-char) '()))))
|