blob: ebf7413f88a8fce95e670baa18e67efceaac5984 (
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
52
53
54
|
#
# Regular Definitions
#
rl rl_ws /[.+ \t\n\r\v]+/
rl rl_id /[a-zA-Z_][a-zA-Z0-9_]*/
#
# Tokens
#
lex start
{
literal '=', '<', '>', '/'
# Ignore whitespace.
ignore /rl_ws/
# Open and close id
token id /rl_id/
}
#
# Productions
#
def attr [id '=' id]
def attr_list
[attr_list attr]
| []
def open_tag
['<' id attr_list '>']
def close_tag
['<' '/' id '>']
def tag
[open_tag item_list close_tag]
def item_list
[item_list tag]
| []
parse Attrs: attr_list( stdin )
print( Attrs '\n' )
## Reconstruct the left hand side with the
construct IL: item_list
["<wrapper .[Attrs]. ></wrapper>"]
print( IL '\n' )
|