318
|
1
|
357
|
2 %tokens ':' ';' '(' ')' ',' string 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
|
357
|
23 rule: id ':' tree cost string { self.system.add_rule($1.val, $3, $4, None, $5.val) };
|
|
24 rule: id ':' tree cost string string { self.system.add_rule($1.val, $3, $4, $5.val, $6.val) };
|
318
|
25
|
319
|
26 cost: number { return $1.val };
|
318
|
27
|
319
|
28 tree: id { return self.system.tree($1.val) }
|
|
29 | id '(' tree ')' { return self.system.tree($1.val, $3) }
|
|
30 | id '(' tree ',' tree ')' { return self.system.tree($1.val, $3, $5) };
|
|
31
|