annotate python/burg.x @ 393:6ae782a085e0

Added init program
author Windel Bouwman
date Sat, 17 May 2014 21:17:40 +0200
parents 818be710e13d
children
rev   line source
318
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
1
357
818be710e13d Added acceptance function to burg
Windel Bouwman
parents: 322
diff changeset
2 %tokens ':' ';' '(' ')' ',' string id number '%%' '%terminal' header
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
322
44f336460c2a Half of use of burg spec for arm
Windel Bouwman
parents: 319
diff changeset
6 burgdef: header '%%' directives '%%' rules { self.system.header_lines = $1.val };
319
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
357
818be710e13d Added acceptance function to burg
Windel Bouwman
parents: 322
diff changeset
23 rule: id ':' tree cost string { self.system.add_rule($1.val, $3, $4, None, $5.val) };
818be710e13d Added acceptance function to burg
Windel Bouwman
parents: 322
diff changeset
24 rule: id ':' tree cost string string { self.system.add_rule($1.val, $3, $4, $5.val, $6.val) };
318
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
25
319
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
26 cost: number { return $1.val };
318
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
27
319
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
28 tree: id { return self.system.tree($1.val) }
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
29 | id '(' tree ')' { return self.system.tree($1.val, $3) }
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
30 | id '(' tree ',' tree ')' { return self.system.tree($1.val, $3, $5) };
8d07a4254f04 Work on burg
Windel Bouwman
parents: 318
diff changeset
31