blob: 519ab91293b9c0ee9dff56fb6b3a3fbc17ef572e (
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
|
# 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>
|