summaryrefslogtreecommitdiffstats
path: root/grammar/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'grammar/utils.c')
-rw-r--r--grammar/utils.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/grammar/utils.c b/grammar/utils.c
index c26a856c..bc300aaf 100644
--- a/grammar/utils.c
+++ b/grammar/utils.c
@@ -233,11 +233,20 @@ struct cnfexpr*
cnfexprNew(int nodetype, struct cnfexpr *l, struct cnfexpr *r)
{
struct cnfexpr *expr;
+
+ /* optimize some constructs during parsing */
+ if(nodetype == 'M' && r->nodetype == 'N') {
+ ((struct cnfnumval*)r)->val *= -1;
+ expr = r;
+ goto done;
+ }
+
if((expr = malloc(sizeof(struct cnfexpr))) != NULL) {
expr->nodetype = nodetype;
expr->l = l;
expr->r = r;
}
+done:
return expr;
}