]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Original `expr' is back, filter expressions renamed to `term'.
authorMartin Mares <mj@ucw.cz>
Fri, 15 Jan 1999 18:04:28 +0000 (18:04 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 15 Jan 1999 18:04:28 +0000 (18:04 +0000)
In the future, we'll allow any filter term in place of `expr' and we'll
just evaluate it immediately, but not now as we have no evaluation
routines.

conf/confbase.Y
filter/config.Y

index 116cc8b63bfa34ef9f76c3f3af3250db4cb4076c..a5d6838216ce3594b52c7ce781af16c24be20e73 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     BIRD -- Configuration Parser Top
  *
- *     (c) 1998 Martin Mares <mj@ucw.cz>
+ *     (c) 1998--1999 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -34,7 +34,7 @@ CF_DECLS
 %token <s> SYM
 %token <t> TEXT
 
-%type <i> cexpr bool pxlen
+%type <i> expr bool pxlen
 
 %left '+' '-'
 %left '*' '/' '%'
@@ -59,20 +59,20 @@ CF_ADDTO(conf, /* EMPTY */)
 
 /* Constant expressions */
 
-cexpr:
+expr:
    NUM
- | cexpr '+' cexpr { $$ = $1 + $3; }
- | cexpr '-' cexpr { $$ = $1 - $3; }
- | cexpr '*' cexpr { $$ = $1 * $3; }
- | cexpr '/' cexpr { if ($3) $$ = $1 / $3; else cf_error("Division by zero"); }
- | cexpr '%' cexpr { if ($3) $$ = $1 % $3; else cf_error("Division by zero"); }
- | '(' cexpr ')' { $$ = $2; }
+ | expr '+' expr { $$ = $1 + $3; }
+ | expr '-' expr { $$ = $1 - $3; }
+ | expr '*' expr { $$ = $1 * $3; }
+ | expr '/' expr { if ($3) $$ = $1 / $3; else cf_error("Division by zero"); }
+ | expr '%' expr { if ($3) $$ = $1 % $3; else cf_error("Division by zero"); }
+ | '(' expr ')' { $$ = $2; }
  | SYM { if ($1->class != SYM_NUMBER) cf_error("Number expected"); else $$ = $1->aux; }
  ;
 
 CF_ADDTO(conf, definition)
 definition:
-   DEFINE SYM '=' cexpr {
+   DEFINE SYM '=' expr {
      if ($2->class != SYM_VOID) cf_error("Symbol already defined");
      $2->class = SYM_NUMBER;
      $2->aux = $4;
@@ -82,7 +82,7 @@ definition:
 /* Switches */
 
 bool:
-   cexpr {$$ = !!$1; }
+   expr {$$ = !!$1; }
  | ON { $$ = 1; }
  | YES { $$ = 1; }
  | OFF { $$ = 0; }
index 265463d35045b0b02d7a3813ca1d5d18a636f59a..17f687a271f927cfec4bf5ee01282e0679ad479f 100644 (file)
@@ -21,7 +21,7 @@ CF_DECLS
 
 CF_KEYWORDS(FUNCTION, FILTER, PRINTDEBUG, INT, PRINT)
 
-%type <x> expr
+%type <x> term
 
 CF_GRAMMAR
 
@@ -38,7 +38,7 @@ program: /* EMPTY */
 
 CF_ADDTO(conf, function)
 function:
-   FUNCTION SYM '(' ')' '{' expr '}' { 
+   FUNCTION SYM '(' ')' '{' term '}' { 
      extern struct f_instruction *last_func;
      if ($2->class != SYM_VOID) cf_error("Symbol already defined" );
      $2->class = SYM_FUNCTION;
@@ -50,7 +50,7 @@ function:
 
 CF_ADDTO(conf, filter)
 filter:
-   FILTER SYM '{' expr '}' {
+   FILTER SYM '{' term '}' {
      if ($2->class != SYM_VOID) cf_error("Symbol already defined" );
      $2->class = SYM_FILTER;
      $2->aux = $4;
@@ -60,8 +60,8 @@ filter:
 
 /* Programs */
 
-expr: /* EMPTY */ { $$ = NULL; }
- | expr ';' expr { 
+term: /* EMPTY */ { $$ = NULL; }
+ | term ';' term { 
      $$ = cfg_alloc(sizeof(struct f_instruction));
      printf( "We've got statement here\n" );
      $$->code = ',';
@@ -74,7 +74,7 @@ expr: /* EMPTY */ { $$ = NULL; }
      printf( "New variable\n" );
      $$ = NULL;
    }
- | SYM '=' cexpr {
+ | SYM '=' expr {
      $$ = cfg_alloc(sizeof(struct f_instruction));
      printf( "Ook, we'll set value\n" );
      if ($1->class != SYM_VARIABLE_INT)