summaryrefslogtreecommitdiff
path: root/test/btscan1.lm
blob: 558b890619ce32438f02f25894c624cc497c8976 (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
##### LM #####
#
# R1
#
namespace r1

	lex
		literal `! `a `b
		ignore /[ \n\t]+/
	end

	def line [ `! `a `b `b `a]

end # r1

#
# R2
#
namespace r2

	lex
		literal `!
		token id /[a-zA-Z_]+/
		ignore /[ \n\t]+/
	end

	def line [ `! id ]

end # r2

def item 
	[r1::line]
|	[r2::line]

def btscan 
	[item*]

parse P: btscan[ stdin ]

match P ~!abb !abba !aab
print_xml(P)
print( '\n' )
##### IN #####
!abb !abba !aab

##### EXP #####
<btscan><_repeat_item><item><r2::line><r2::_literal_0009>!</r2::_literal_0009><r2::id>abb</r2::id></r2::line></item><item><r1::line><r1::_literal_0001>!</r1::_literal_0001><r1::_literal_0003>a</r1::_literal_0003><r1::_literal_0005>b</r1::_literal_0005><r1::_literal_0005>b</r1::_literal_0005><r1::_literal_0003>a</r1::_literal_0003></r1::line></item><item><r2::line><r2::_literal_0009>!</r2::_literal_0009><r2::id>aab</r2::id></r2::line></item></_repeat_item></btscan>