summaryrefslogtreecommitdiff
path: root/test/matchex.lm
blob: 2212f4bcb7ad17bcfefc789c4eef54beb9e81635 (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 start
{
	token id /[a-zA-Z_][a-zA-Z0-9_]*/
	literal '=', '<', '>', '/'
	ignore /[ \t\n\r\v]+/
}

def attr 
	[id '=' id]

def open_tag 
	['<' id attr* '>']

def close_tag
	['<' '/' id '>']

def tag 
	[open_tag item* close_tag]

def item
	[tag]
|	[id]

Tag: tag = parse tag( stdin )

# Style: List of literal text and types.
match Tag ["<person name=" Val1:id attr*">" item* "</person>"]

# Style: Literal text with embedded lists of types.
match Tag "<person name=[Val2:id attr*]>[item*]</person>"

print( Val1 '\n' )
print( Val2 '\n' )