blob: fa7317a45091e4630ef430f3a7020ef166fd8090 (
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
32
33
34
35
36
37
38
39
40
|
# Token names.
lex start
{
token number /[0-9]+/
token id /[a-z]+/
token string /'"' [^"]* '"'/
ignore ws / [ \t\n]+ /
}
def prefix [id]
def choice1
[number number]
| [number]
def choice2
[string id]
| [number number]
| [id number]
| [number]
token EOF /ws+/
def start
[prefix choice1 choice2 string id id EOF]
cons I: parser<start> []
I << " id "
I << " 77 "
I << " 88 "
I << " \"hello\" "
I << " dude "
I << " dude\n"
S: start = I.finish()
S = match S
~id 77 88 "hello" dude dude
print_xml( S )
|