From 7abc2604f3538177d5662803befa515a16ea99b4 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Mon, 12 Jul 2004 14:03:53 +0000 Subject: [PATCH] * examples/bddcalc/parser.yxx (actionSeq, varlist): Rewrite as left-recursive rules. --- buddy/ChangeLog | 5 +++++ buddy/examples/bddcalc/parser.yxx | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/buddy/ChangeLog b/buddy/ChangeLog index 7e59a5e20..9b475673a 100644 --- a/buddy/ChangeLog +++ b/buddy/ChangeLog @@ -1,3 +1,8 @@ +2004-07-12 Alexandre Duret-Lutz + + * examples/bddcalc/parser.yxx (actionSeq, varlist): Rewrite as + left-recursive rules. + 2004-06-28 Alexandre Duret-Lutz Merge BuDDy 2.3. diff --git a/buddy/examples/bddcalc/parser.yxx b/buddy/examples/bddcalc/parser.yxx index 3f814c761..082d6b007 100644 --- a/buddy/examples/bddcalc/parser.yxx +++ b/buddy/examples/bddcalc/parser.yxx @@ -20,7 +20,7 @@ /* Definitions for storing and caching of identifiers */ #define inputTag 0 #define exprTag 1 - + struct nodeData { nodeData(const nodeData &d) { tag=d.tag; name=sdup(d.name); val=d.val; } @@ -39,7 +39,7 @@ int linenum; bddgbchandler gbcHandler = bdd_default_gbchandler; - + /* Prototypes */ void actInit(token *nodes, token *cache); void actInputs(void); @@ -48,7 +48,7 @@ void actAssign(token *id, token *expr); void actOpr2(token *res, token *left, token *right, int opr); void actNot(token *res, token *right); void actId(token *res, token *id); -void actConst(token *res, int); +void actConst(token *res, int); void actSize(token *id); void actDot(token *fname, token *id); void actAutoreorder(token *times, token *method); @@ -59,7 +59,7 @@ void actForall(token *res, token *var, token *expr); void actQuantVar2(token *res, token *id, token *list); void actQuantVar1(token *res, token *id); void actPrint(token *id); - + %} /************************************************************************* @@ -119,7 +119,7 @@ actions: ; actionSeq: - action T_semi actionSeq + actionSeq action T_semi | action T_semi ; @@ -159,7 +159,7 @@ quantifier: ; varlist: - T_id varlist { actQuantVar2(&$$,&$1,&$2); } + varlist T_id { actQuantVar2(&$$,&$2,&$1); } | T_id { actQuantVar1(&$$,&$1); } ; @@ -212,7 +212,7 @@ void usage(void) int main(int ac, char **av) { int c; - + while ((c=getopt(ac, av, "hg")) != EOF) { switch (c) @@ -225,7 +225,7 @@ int main(int ac, char **av) break; } } - + if (optind >= ac) usage(); @@ -242,7 +242,7 @@ int main(int ac, char **av) bdd_printstat(); bdd_done(); - + return 0; } @@ -279,7 +279,7 @@ void actInputs(void) { if (names.exists((*i).name)) yyerror("Redefinition of input %s", (*i).name); - + (*i).val = bdd_ithvar(vnum); hashData hd((*i).name, 0, &(*i)); names.add(hd); @@ -299,7 +299,7 @@ void actAssign(token *id, token *expr) { if (names.exists(id->id)) yyerror("Redefinition of %s", id->id); - + nodeData *d = new nodeData(exprTag, sdup(id->id), *expr->bval); hashData hd(d->name, 0, d); names.add(hd);