comparison python/burg.x @ 318:e84047f29c78

Add burg and yacc initial attempts
author Windel Bouwman
date Tue, 31 Dec 2013 12:38:15 +0100
parents
children 8d07a4254f04
comparison
equal deleted inserted replaced
317:e30a77ae359b 318:e84047f29c78
1
2 from tree import Tree
3 %tokens ':' ';' '(' ')' ',' template id number '%%' header
4
5 %%
6
7 rule: id ':' tree template cost { self.add_rule($1, $3, $4, $5) };
8
9 cost: number { return number.val };
10
11 tree: id { return Tree($1) }
12 | id '(' tree ')' { return Tree($1, $3) }
13 | id '(' tree ',' tree ')' { return Tree($1, $3, $5) };
14
15