summaryrefslogtreecommitdiff
path: root/test/colm.d/undolist1.lm
blob: b65d77806ac44ef28ad72acea7533e0cd9c0d4d7 (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
context undo

	lex
		ignore /( ' ' | '\t')+/
		literal `* `( `) `^ `;
		token NL /'\n'/
		token id /[a-zA-Z_]+/
	end

	List: list<item>

	def item 
		[id]
		{
			List->push_tail( lhs )
		}
	|	[`( item* `)]
		{
			List->push_tail( lhs )
		}

	def A1 []
	def A2 []

	def start 
		[A1 item* `^]
	|	[A2 item* `; NL]
	{
		for Item: item in List {
			print "list el: [@Item]
		}
	}

end

Undo: undo = new undo()
Undo->List = new list<undo::item>()

parse Input: undo::start(Undo)[ stdin ]
print[ @Input ]

###### IN #######
a b c ( d e ) f;
###### EXP #######
list el: a 
list el: b 
list el: c 
list el: d 
list el: e 
list el: ( d e ) 
list el: f
a b c ( d e ) f;