318
|
1
|
322
|
2 %tokens ':' ';' '(' ')' ',' template id number '%%' '%terminal' header
|
318
|
3
|
|
4 %%
|
|
5
|
322
|
6 burgdef: header '%%' directives '%%' rules { self.system.header_lines = $1.val };
|
319
|
7
|
|
8 directives:
|
|
9 | directives directive;
|
318
|
10
|
319
|
11 directive: termdef;
|
|
12
|
|
13 termdef: '%terminal' termids;
|
|
14
|
|
15 termids:
|
|
16 | termids termid;
|
318
|
17
|
319
|
18 termid: id { self.system.add_terminal($1.val) };
|
|
19
|
|
20 rules:
|
|
21 | rules rule;
|
|
22
|
|
23 rule: id ':' tree cost template { self.system.add_rule($1.val, $3, $4, $5.val) };
|
318
|
24
|
319
|
25 cost: number { return $1.val };
|
318
|
26
|
319
|
27 tree: id { return self.system.tree($1.val) }
|
|
28 | id '(' tree ')' { return self.system.tree($1.val, $3) }
|
|
29 | id '(' tree ',' tree ')' { return self.system.tree($1.val, $3, $5) };
|
|
30
|