summaryrefslogtreecommitdiff
path: root/test/lhs1.lm
blob: adcfcf992a220cc0aceaa60d0fbb6de8904ac00e (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

lex
	ignore /space+/
	literal '*', '(', ')', '!', ';\n'
	token id /[a-zA-Z_0-9]+/ 
end

def item 
	[id]
	{
		lhs = cons item ["( " ^r1 " )"]
	}
|	['(' item* ')']
	{
		lhs = cons item ["( " ^r2 " )"]
	}

def A 
	[] {
		print( 'A\n' )
	}

def B
	[] {
		print( 'B\n' )
	}

def start 
	[A item* '!']
|	[B item* ';\n']

parse Start: start[ stdin ]
print( Start.tree "\n" )