view python/burg.x @ 321:8c569fbe60e4

Load yacc and burg dynamic
author Windel Bouwman
date Sun, 19 Jan 2014 18:48:45 +0100
parents 8d07a4254f04
children 44f336460c2a
line wrap: on
line source


%tokens ':' ';' '(' ')' ',' template id number '%%' '%terminal'

%%

burgdef: directives '%%' rules;

directives:
          | directives directive;

directive: termdef;

termdef: '%terminal' termids;

termids:
       | termids termid;

termid: id { self.system.add_terminal($1.val) };

rules:
     | rules rule;

rule: id ':' tree cost template { self.system.add_rule($1.val, $3, $4, $5.val) };

cost: number { return $1.val };

tree: id { return self.system.tree($1.val) }
    | id '(' tree ')' { return self.system.tree($1.val, $3) }
    | id '(' tree ',' tree ')' { return self.system.tree($1.val, $3, $5) };