summaryrefslogtreecommitdiff
path: root/test/backtrack2.lm
blob: fa3cdfc97f30c2603871449854410e378683f105 (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
##### LM #####

# Token names.
lex
	token id /[a-z]+/
	ignore ws /[ \t\n]+/
end

token bang1 /'!'/
token bang2 /'!'/

def one [bang1 id id id]

def two [bang2 id id id id]

def prods 
	[one]
|	[two]

def start
	[prods]

parse S: start[ stdin ]
print_xml( match S "!aa bb cc dd" )
print( '\n' )
##### IN #####
!aa bb cc dd
##### EXP #####
<start><prods><two><bang2>!</bang2><id>aa</id><id>bb</id><id>cc</id><id>dd</id></two></prods></start>