blob: a32931424e2c03a2fb9d377ed78a2e9696784afc (
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
|
lex
ignore /space+/
literal `* `( `)
token id /[a-zA-Z_]+/
end
def item
[id]
| [`( item* `)]
def item2
[id]
| [`( item2* `)]
def start
[item*]
StartParser1: parser<start> = new parser<start>()
StartParser2: parser<start> = new parser<start>()
parse Item2: item2 "b
# Success.
send StartParser1
"a [Item2] c d\n" eos
# Failure.
send_tree StartParser2
"a [Item2] c d\n" eos
print( StartParser1->tree )
print( StartParser2->tree "\n" )
######### EXP #########
a b c d
NIL
|