blob: a74bb6db7b23250bfb7a43e826696fadd84af4c8 (
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
55
56
57
58
59
60
|
lex start
{
literal '!', 'a', ';\n'
token id /'a'|'b'/
{
input.push( make_token( trans_id_to input.pull(match_length) ) )
}
token super_id //
token foo //
ignore ws / [ \n\t]+ /
}
global trans_id_to: int
def e1
[]
{
print( 'old_id = ' trans_id_to '\n' )
trans_id_to = typeid<foo>
print( 'new_id = ' trans_id_to '\n' )
}
def item1
msg: str
[ e1 '!' 'a' super_id super_id 'a']
{
lhs.msg = 'this is item1\n'
}
def e2
[]
{
print( 'old_id = ' trans_id_to '\n' )
trans_id_to = typeid<super_id>
print( 'new_id = ' trans_id_to '\n' )
}
def item2
msg: str
[ e2 '!' 'a' super_id super_id 'a']
{
lhs.msg = 'this is item2\n'
}
def start
[item1 ';\n']
| [item2 ';\n']
{
match lhs [Item2:item2 ';\n']
print( Item2.msg )
}
print_xml( parse start(stdin) )
|