]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Allow other operations than +.
authorPavel Machek <pavel@ucw.cz>
Mon, 15 May 2000 12:27:45 +0000 (12:27 +0000)
committerPavel Machek <pavel@ucw.cz>
Mon, 15 May 2000 12:27:45 +0000 (12:27 +0000)
filter/config.Y
filter/filter.c
filter/test.conf

index 0d1d716fbb386a6c9ad8f96aa3166b09696e6af5..a99e4a5468042d2ea87b24c21932bbd94bd0d687 100644 (file)
@@ -334,6 +334,9 @@ function_call:
 term:
    '(' term ')'      { $$ = $2; }
  | term '+' term     { $$ = f_new_inst(); $$->code = '+';        $$->a1.p = $1; $$->a2.p = $3; }
+ | term '-' term     { $$ = f_new_inst(); $$->code = '-';        $$->a1.p = $1; $$->a2.p = $3; }
+ | term '*' term     { $$ = f_new_inst(); $$->code = '*';        $$->a1.p = $1; $$->a2.p = $3; }
+ | term '/' term     { $$ = f_new_inst(); $$->code = '/';        $$->a1.p = $1; $$->a2.p = $3; }
  | term '=' term     { $$ = f_new_inst(); $$->code = P('=','='); $$->a1.p = $1; $$->a2.p = $3; }
  | term NEQ term { $$ = f_new_inst(); $$->code = P('!','=');     $$->a1.p = $1; $$->a2.p = $3; }
  | term '<' term     { $$ = f_new_inst(); $$->code = '<';        $$->a1.p = $1; $$->a2.p = $3; }
index 84680c66b39ae2fc4c689972fdc7ec06ce822970..344368e68fb89a838525e5160b6f42d0b143c6ca 100644 (file)
@@ -230,6 +230,22 @@ interpret(struct f_inst *what)
     default: runtime( "Usage of unknown type" );
     }
     break;
+  case '-':
+    TWOARGS_C;
+    switch (res.type = v1.type) {
+    case T_VOID: runtime( "Can not operate with values of type void" );
+    case T_INT: res.val.i = v1.val.i - v2.val.i; break;
+    default: runtime( "Usage of unknown type" );
+    }
+    break;
+  case '*':
+    TWOARGS_C;
+    switch (res.type = v1.type) {
+    case T_VOID: runtime( "Can not operate with values of type void" );
+    case T_INT: res.val.i = v1.val.i * v2.val.i; break;
+    default: runtime( "Usage of unknown type" );
+    }
+    break;
   case '/':
     TWOARGS_C;
     switch (res.type = v1.type) {
@@ -582,6 +598,8 @@ i_same(struct f_inst *f1, struct f_inst *f2)
   switch(f1->code) {
   case ',': /* fall through */
   case '+':
+  case '-':
+  case '*':
   case '/':
   case P('!','='):
   case P('=','='):
index d734d57ce55f10f8cf852ab90266d6f628cdab4e..bce8cfec91de1c9f9804cb7e520e30e5abfe23c8 100644 (file)
@@ -6,7 +6,7 @@
 
 router id 62.168.0.1;
 
-define xyzzy = 120+10;
+#define xyzzy = 120+10;
 
 function callme(int arg1; int arg2)
 int local1;
@@ -75,7 +75,7 @@ ip p;
 { 
        print "Testing filter language:";
        i = four; 
-       i = 1230 + i; 
+       i = 12*100 + 60/2 + i; 
        i = ( i + 0 );
        print "  arithmetics: 1234 = ", i;
        printn "  if statements ";