]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Syntax of sets improved.
authorOndrej Filip <feela@network.cz>
Tue, 3 Aug 2010 13:14:26 +0000 (15:14 +0200)
committerOndrej Filip <feela@network.cz>
Tue, 3 Aug 2010 13:16:25 +0000 (15:16 +0200)
doc/bird.sgml
filter/config.Y
filter/test.conf

index 266c449093e4414bdbe3da9a49e1a3417368620a..c46ea4f01a85e347d3b6ef9bc0814dea13211c00 100644 (file)
@@ -707,7 +707,8 @@ incompatible with each other (that is to prevent you from shooting in the foot).
          but you can't modify them. Literals of type <cf>int set</cf> look like <cf>
          [ 1, 2, 5..7 ]</cf>. As you can see, both simple values and ranges are permitted in
          sets. For pair sets, expressions like <cf/(123,*)/ can be used to denote ranges (in
-         that case <cf/(123,0)..(123,65535)/).
+         that case <cf/(123,0)..(123,65535)/). You can also use <cf/(123,5..100/ for range
+         <cf/(123,5)..(123,100)/.
 
          Sets of prefixes are special: their literals does not allow ranges, but allows
          prefix patterns that are written as <cf><M>ipaddress</M>/<M>pxlen</M>{<M>low</M>,<M>high</M>}</cf>.
index 0b507ff2fc466044ebd463baea8b0c81c71faf4f..698f920b937205150a09441d1f663bd0ea6827f1 100644 (file)
@@ -45,7 +45,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
 
 %type <x> term block cmds cmds_int cmd function_body constant print_one print_list var_list var_listn dynamic_attr static_attr function_call symbol dpair bgp_path_expr
 %type <f> filter filter_body where_filter
-%type <i> type break_command cpair
+%type <i> type break_command
 %type <e> set_item set_items switch_body
 %type <trie> fprefix_set
 %type <v> set_atom fprefix fprefix_s fipa
@@ -220,13 +220,6 @@ block:
    }
  ;
 
-/*
- * Simple types, their bison value is int
- */
-cpair:
-   '(' NUM ',' NUM ')' { $$ = make_pair($2, $4); }
- ;
-
 /*
  * Complex types, their bison value is struct f_val
  */
@@ -237,13 +230,30 @@ fipa:
 set_atom:
    NUM   { $$.type = T_INT; $$.val.i = $1; }
  | RTRID { $$.type = T_QUAD; $$.val.i = $1; }
- | cpair { $$.type = T_PAIR; $$.val.i = $1; }
  | fipa  { $$ = $1; }
  | ENUM  {  $$.type = $1 >> 16; $$.val.i = $1 & 0xffff; }
  ; 
 
 set_item:
-   '(' NUM ',' '*' ')' { 
+   '(' expr ',' expr ')' {
+       $$ = f_new_tree(); 
+       $$->from.type = $$->to.type = T_PAIR;
+       $$->from.val.i = make_pair($2, $4); 
+       $$->to.val.i = make_pair($2, $4);
+   }
+ | '(' expr ',' expr '.' '.' expr ')' { 
+       $$ = f_new_tree(); 
+       $$->from.type = $$->to.type = T_PAIR;
+       $$->from.val.i = make_pair($2, $4); 
+       $$->to.val.i = make_pair($2, $7);
+   }
+ | '(' expr ',' expr ')' '.' '.' '(' expr ',' expr ')' { 
+       $$ = f_new_tree(); 
+       $$->from.type = $$->to.type = T_PAIR;
+       $$->from.val.i = make_pair($2, $4); 
+       $$->to.val.i = make_pair($9, $11);
+   }
+ |  '(' expr ',' '*' ')' { 
        $$ = f_new_tree(); 
        $$->from.type = $$->to.type = T_PAIR;
        $$->from.val.i = make_pair($2, 0); 
index 48143960811072126d528a63d0ccea01d9340428..18121c4ef7d0d65d9a43aa5b8fb9b90920573774 100644 (file)
@@ -9,6 +9,7 @@ router id 62.168.0.1;
 
 define xyzzy = (120+10);
 define '1a-a1' = (20+10);
+define one = 1;
 
 
 function 'mkpair-a'(int a)
@@ -76,14 +77,26 @@ clist l;
        print "Should be true: ", p2 ~ pm1, " ", p2, " ", pm1;
 
        l = - empty -;
-       l = add( l, (1,2) );
-       l = add( l, (2,3) );
+       l = add( l, (one,2) );
+       l = add( l, (2,one+2) );
        print "Community list (1,2) (2,3) ", l;
-       print "Should be true: ", (2,3) ~ l, " ", l ~ [(1,*)], " ", l ~ [(2,3)];
+       print "Should be true: ", (2,3) ~ l, " ", l ~ [(1,*)], " ", l ~ [(2,3)]," ", l ~ [(2,2..3)], " ", l ~ [(1,1..2)], " ", l ~ [(1,1)..(1,2)];
        l = add( l, (2,5) );
+       l = add( l, (5,one) );
+       l = add( l, (6,one) );
+       l = add( l, (one,one) );
+       l = delete( l, [(5,1),(6,one),(one,1)] );
+       l = delete( l, [(5,one),(6,one)] );
        l = delete( l, [(2,*)] );
        print "Community list (1,2) ", l;
-       print "Should be false: ", (2,3) ~ l, " ", l ~ [(2,*)];
+       print "Should be false: ", (2,3) ~ l, " ", l ~ [(2,*)], " ", l ~ [(one,3..6)];
+       l = add( l, (3,one) );
+       l = add( l, (one+one+one,one+one) );
+       l = add( l, (3,3) );
+       l = add( l, (3,4) );
+       l = add( l, (3,5) );
+       l = delete( l, [(3,2..4)] );
+       print "Community list (1,2) (3,1) (3,5) ", l;
 }
 
 function bla()