]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Added && and ||.
authorPavel Machek <pavel@ucw.cz>
Thu, 1 Jun 2000 08:43:29 +0000 (08:43 +0000)
committerPavel Machek <pavel@ucw.cz>
Thu, 1 Jun 2000 08:43:29 +0000 (08:43 +0000)
conf/cf-lex.l
conf/confbase.Y
filter/config.Y
filter/filter.c
filter/test.conf

index 22f029594fb8febab6d57fa968497684c717eb2f..a30ddfbdecde455897ae9ec90152873a1e41450a 100644 (file)
@@ -179,6 +179,8 @@ WHITE [ \t]
 \!\= return NEQ;
 \<\= return LEQ;
 \>\= return GEQ;
+\&\& return AND;
+\|\| return OR;
 
 %%
 
index b48a929019ef9c31020243dfdbc2cb8cf2e94905..5da84b1e6a949ffd72cff5920e8d66591b84f8a8 100644 (file)
@@ -44,7 +44,7 @@ CF_DECLS
 }
 
 %token END CLI_MARKER INVALID_TOKEN
-%token GEQ LEQ NEQ
+%token GEQ LEQ NEQ AND OR
 %token <i> NUM ENUM
 %token <i32> RTRID
 %token <a> IPA
@@ -57,7 +57,7 @@ CF_DECLS
 %type <px> prefix prefix_or_ipa
 
 %nonassoc PREFIX_DUMMY
-%nonassoc '=' '<' '>' '~' '.' GEQ LEQ NEQ
+%nonassoc '=' '<' '>' '~' '.' GEQ LEQ NEQ AND OR
 %left '+' '-'
 %left '*' '/' '%'
 %left '!'
index 1ab43058b0e5d6477afb8f2e95208b9ab95b0512..545b5e32fea67a91bef8597d42c15257c33b411c 100644 (file)
@@ -343,6 +343,8 @@ term:
  | 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 AND term     { $$ = f_new_inst(); $$->code = '&';        $$->a1.p = $1; $$->a2.p = $3; }
+ | term OR  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 6a4778b996a0896d1bd5ed50081d4f7ef4b54110..232a2d2ce159f0ee5667a678f5e3a47e95e9a9ee 100644 (file)
@@ -290,6 +290,19 @@ interpret(struct f_inst *what)
     default: runtime( "Usage of unknown type" );
     }
     break;
+    
+  case '&':
+    TWOARGS_C;
+    res.type = v1.type;
+    if (res.type != T_BOOL) runtime( "Can not do boolean operation on non-booleans" );
+    res.val.i = v1.val.i && v2.val.i;
+    break;
+  case '|':
+    TWOARGS_C;
+    res.type = v1.type;
+    if (res.type != T_BOOL) runtime( "Can not do boolean operation on non-booleans" );
+    res.val.i = v1.val.i || v2.val.i;
+    break;
 
 /* Relational operators */
 
@@ -665,6 +678,8 @@ i_same(struct f_inst *f1, struct f_inst *f2)
   case '-':
   case '*':
   case '/':
+  case '|':
+  case '&':
   case P('!','='):
   case P('=','='):
   case '<':
index 7e674647563458193b32b86da70ee6373d97c19e..c1d5977d3565482b4088d011b5364e68ea35c5c1 100644 (file)
@@ -88,9 +88,10 @@ ip p;
        if 1234 < 1234 then { print "*** FAIL: test 4"; quitbird; } else print "ok";
        print "  must be true: ", 1.2.0.0/16 ~ [ 1.0.0.0/8{ 15 , 17 } ];
        print "  data types; must be true: ", 1.2.3.4 = 1.2.3.4, ",", 1 ~ [1,2,3], ",", 5 ~ [1..20], ",", 2 ~ [ 1, 2, 3 ], ",", 5 ~ [ 4 .. 7 ], ",", 1.2.3.4 ~ [ 1.2.3.3..1.2.3.5 ], ",", 1.2.3.4 ~ 1.0.0.0/8, ",", 1.0.0.0/8 ~ 1.0.0.0/8, ",", 1.0.0.0/8 ~ [ 1.0.0.0/8+ ];
+       print "  must be true: ", true && true, ",", true || false;
 
 #      print "  must be true: ", defined(1), ",", defined(1.2.3.4), ",", 1 != 2, ",", 1 <= 2;
-       print "  data types: must be false: ", 1 ~ [ 2, 3, 4 ], ",", 5 ~ [ 2, 3, 4, 7..11 ], ",", 1.2.3.4 ~ [ 1.2.3.3, 1.2.3.5 ], ",", (1,2) > (2,2), ",", (1,1) > (1,1), ",", 1.0.0.0/8 ~ [ 1.0.0.0/8- ], ",", 1.2.0.0/17 ~ [ 1.0.0.0/8{ 15 , 16 } ];
+       print "  data types: must be false: ", 1 ~ [ 2, 3, 4 ], ",", 5 ~ [ 2, 3, 4, 7..11 ], ",", 1.2.3.4 ~ [ 1.2.3.3, 1.2.3.5 ], ",", (1,2) > (2,2), ",", (1,1) > (1,1), ",", 1.0.0.0/8 ~ [ 1.0.0.0/8- ], ",", 1.2.0.0/17 ~ [ 1.0.0.0/8{ 15 , 16 } ], ",", true && false;
 
        px = 1.2.0.0/18;
        print "Testing prefixes: 1.2.0.0/18 = ", px;