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

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

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" )