blob: df2a648a0ae5a9dfdc493b9b7513dc2553c3a142 (
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
|
context undo
lex
ignore /( ' ' | '\t')+/
literal `* `( `) `^ `;
token NL /'\n'/
token id /[a-zA-Z_]+/
end
Map: map<item, item>
def item
[id]
{
Map->insert( lhs, lhs )
}
| [`( item* `)]
{
Map->insert( lhs, lhs )
}
def A1 []
def A2 []
def start
[A1 item* `^]
| [A2 item* `; NL]
{
for I: item in Map
print "map el: [@I]
}
end
Undo: undo = new undo()
Undo->Map = new map<undo::item, undo::item>()
parse Input: undo::start(Undo)[ stdin ]
print[ @Input ]
###### IN #######
a b c ( d e ) f;
###### EXP #######
map el: ( d e )
map el: a
map el: b
map el: c
map el: d
map el: e
map el: f
a b c ( d e ) f;
|