diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/burg.x	Tue Dec 31 12:38:15 2013 +0100
@@ -0,0 +1,15 @@
+
+from tree import Tree
+%tokens ':' ';' '(' ')' ',' template id number '%%' header
+
+%%
+
+rule: id ':' tree template cost { self.add_rule($1, $3, $4, $5) };
+
+cost: number { return number.val };
+
+tree: id { return Tree($1) }
+    | id '(' tree ')' { return Tree($1, $3) }
+    | id '(' tree ',' tree ')' { return Tree($1, $3, $5) };
+
+