summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--grammar/mini.samp2
-rw-r--r--grammar/utils.c9
2 files changed, 10 insertions, 1 deletions
diff --git a/grammar/mini.samp b/grammar/mini.samp
index 6aae758d..9e00b7cf 100644
--- a/grammar/mini.samp
+++ b/grammar/mini.samp
@@ -24,7 +24,7 @@ if 1 then { /var/log/log3
@@fwd
rger
}
-if 2*4/5--(10-3)/*pri("*.*")*/ then {
+if 2*4/-5--(10-3)/*pri("*.*")*/ then {
action(type="omfile" taget="/var/log/log5")
action(type="omfile" taget="/var/log/log6")
action(type="omfwd" taget="10.0.0.1" port="514")
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;
}