summaryrefslogtreecommitdiff
path: root/test/accum1.lm
blob: 4c5ea960dae0d3f4a4bfa22ee3d6b1e8de5b5b16 (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
##### LM #####
lex
	ignore /space+/
	literal '*', '(', ')'
	token id /[a-zA-Z_]+/
end

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

def start 
	[item*]

parse Input: start[ stdin ]
InputTree: start = Input.tree

cons Output: accum<start> []

for Id: id in InputTree {
	send Output
		"( [^Id] )
}

S: start = Output()

print( S '\n' )
##### IN #####
a b c ( chocolate fudge ) d e
##### EXP #####
( a )
( b )
( c )
( chocolate )
( fudge )
( d )
( e )