summaryrefslogtreecommitdiff
path: root/test/repeat1.lm
blob: 315a63e24f7244f2097db641235f2f6b6960b4d4 (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
##### LM #####
lex
	ignore /space+/
	literal `* `( `)
	token id /[a-zA-Z_]+/
end

def item 
	[id]
|	[`( item* `)]

def start 
	[item*]

parse Input: start[ stdin ]

match Input [ItemList: item*]

for I: item* in repeat( ItemList )
	print( ^I '\n' )

for I: item* in rev_repeat( ItemList )
	print( ^I '\n' )
##### IN #####
a b ( c d ) e ( f g ) h i
##### EXP #####
a b ( c d ) e ( f g ) h i
b ( c d ) e ( f g ) h i
( c d ) e ( f g ) h i
e ( f g ) h i
( f g ) h i
h i
i


i
h i
( f g ) h i
e ( f g ) h i
( c d ) e ( f g ) h i
b ( c d ) e ( f g ) h i
a b ( c d ) e ( f g ) h i