summaryrefslogtreecommitdiff
path: root/test/ignore5.lm
blob: 28a339278752b7c1570688f5214e8aacf122662a (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
43
44
45
46
47
48
49
50
51
##### LM #####
lex
	ignore /space+/
	literal `* `! `;
	literal `( -ni ni- `)
	token id /[a-zA-Z_0-9]+/ 
end

lex
	ignore /space+/
	token inner_t /[a-zA-Z_0-9]+/ 

	token empty -
end

def inner
	[empty inner_t*]

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

def start 
	[item* `;]

parse Start: start[ stdin ]

if ( ! Start ) {
	print( 'parse error\n' )
	exit( 0 )
}

for I: item in Start {
	print( 'item: .' I '.\n' )
	if match I [ O: `( Inner: inner C: `) ]
		print( 'innr: .' O '.' Inner '.' C '.\n' )
}

##### IN #####
a b c (   d   ) e (  ) f g;
##### EXP #####
item: .a .
item: .b .
item: .c .
item: .(   d   ) .
innr: .(.   d   .) .
item: .e .
item: .(  ) .
innr: .(.  .) .
item: .f .
item: .g.