annotate python/burg.x @ 319:8d07a4254f04

Work on burg
author Windel Bouwman
date Sat, 18 Jan 2014 18:58:43 +0100
parents e84047f29c78
children 44f336460c2a
rev   line source
318
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
1
319
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
2 %tokens ':' ';' '(' ')' ',' template id number '%%' '%terminal'
318
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
3
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
4 %%
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
5
319
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
6 burgdef: directives '%%' rules;
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
7
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
8 directives:
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
9 | directives directive;
318
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
10
319
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
11 directive: termdef;
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
12
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
13 termdef: '%terminal' termids;
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
14
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
15 termids:
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
16 | termids termid;
318
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
17
319
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
18 termid: id { self.system.add_terminal($1.val) };
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
19
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
20 rules:
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
21 | rules rule;
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
22
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
23 rule: id ':' tree cost template { self.system.add_rule($1.val, $3, $4, $5.val) };
318
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
24
319
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
25 cost: number { return $1.val };
318
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
26
319
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
27 tree: id { return self.system.tree($1.val) }
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
28 | id '(' tree ')' { return self.system.tree($1.val, $3) }
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
29 | id '(' tree ',' tree ')' { return self.system.tree($1.val, $3, $5) };
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
30