-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparser.l
57 lines (53 loc) · 827 Bytes
/
parser.l
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(do
(defun parse_quoted (c)
(while (and
(ne (assign c (getchar)) -1)
(ne c 34))
(do (putchar c))
)
)
(defun parse (c sep)
(while (and
(ne (assign c (getchar)) -1)
(ne c 41))
(do
(if (eq c 40)
(do
(printf "[")
(parse 0 0)
(printf "]")
(assign sep 1)
)
(if (eq c 34)
(do
(putchar 34)
(parse_quoted 0)
(putchar 34)
(assign sep 1)
)
(do
(if (and (isspace c) sep)
(do
(printf ",")
(assign sep 0)
)
)
(if (and (isalnum c) (not sep))
(do
(assign sep 1)
(if (not (isdigit c)) (printf ":"))
)
)
(putchar c)
)
)
)
)
)
)
(puts "require 'compiler'\\n")
(puts "prog = [:do,")
(parse 0 0)
(puts "]\n\n")
(puts "Compiler.new.compile(prog)")
)