blob: 53f91dcdb9f9c78bbd1e87bd8aa0194e03379802 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
##### LM #####
context accum_bt
lex
ignore /[ \t\n]+/
token id1 /[a-zA-Z_][a-zA-Z_0-9]*/
def one [ id1* ]
end
OneParser: accum<one>
lex
ignore /[ \t]+/
token id2 /[a-zA-Z_][a-zA-Z_0-9]*/
literal '!', ';', '\n'
def A1 []
{ print( "A1\n" ) }
def A2 []
{ print( "A2\n" ) }
def item2
[id2]
{
send OneParser [' extra ']
send OneParser [$r1]
}
def two
[A1 item2* '!' '\n']
| [A2 item2* ';' '\n']
end
end # accum_bt
AccumBt: accum_bt = cons accum_bt[]
AccumBt.OneParser = cons parser<accum_bt::one>[]
parse TwoParser: accum_bt::two(AccumBt)[ stdin ]
Two: accum_bt::two = TwoParser.tree
send AccumBt.OneParser ['\n']
print( Two )
print( ^( AccumBt.OneParser.finish() ) '\n' )
##### IN #####
a b c d e ;
##### EXP #####
A1
A2
a b c d e ;
extra a extra b extra c extra d extra e
|