summaryrefslogtreecommitdiff
path: root/test/lhs1.lm
blob: f40297f99140a491ffd725634e67ab1fa0b6163f (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 SEMI_NL /';\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* SEMI_NL]

parse Start: start[ stdin ]
print( Start "\n" )
##### IN #####
a b c ( d1 d2 ) e f g ;
##### EXP #####
A
B
( a )( b )( c )( ( d1 )( d2 ) )( e )( f )( g );