summaryrefslogtreecommitdiffstats
path: root/filter/config.Y
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>1999-03-08 21:30:06 +0100
committerPavel Machek <pavel@ucw.cz>1999-03-08 21:30:06 +0100
commitb7005824453583d1459b49c5a424b50e2ea9a2c8 (patch)
tree23579261136bbf4a67a5a50789bebb46bce1e7e5 /filter/config.Y
parent111213f0b66cff8f562f7d9117c9080a9882129e (diff)
downloadbird-b7005824453583d1459b49c5a424b50e2ea9a2c8.tar
bird-b7005824453583d1459b49c5a424b50e2ea9a2c8.zip
Filters are now a tiny bit stronger (if is actually working ;-)
Diffstat (limited to 'filter/config.Y')
-rw-r--r--filter/config.Y51
1 files changed, 47 insertions, 4 deletions
diff --git a/filter/config.Y b/filter/config.Y
index 73a7588..bdaedaa 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -19,7 +19,7 @@ CF_HDR
CF_DECLS
-CF_KEYWORDS(FUNCTION, FILTER, PRINTDEBUG, INT, PRINT)
+CF_KEYWORDS(FUNCTION, FILTER, PRINTDEBUG, INT, PRINT, CONST, VAR, PUTS, DIE, IF)
%type <x> term
%type <x> cmds
@@ -29,7 +29,7 @@ CF_GRAMMAR
CF_ADDTO(conf, function)
function:
FUNCTION SYM '(' ')' '{' cmds '}' {
- extern struct f_instruction *last_func;
+ extern struct f_inst *last_func;
if ($2->class != SYM_VOID) cf_error("Symbol already defined" );
$2->class = SYM_FUNCTION;
$2->def = $6;
@@ -69,13 +69,47 @@ term:
/* EMPTY */ {
$$ = NULL;
}
+ | term '+' term {
+ $$ = f_new_inst();
+ $$->code = '+';
+ $$->arg1 = $1;
+ $$->arg2 = $3;
+ }
+ | IF '(' term ')' '{' cmds '}' {
+ $$ = f_new_inst();
+ $$->code = '?';
+ $$->arg1 = $3;
+ $$->arg2 = $6;
+ }
+ | IF '(' term ')' term {
+ $$ = f_new_inst();
+ $$->code = '?';
+ $$->arg1 = $3;
+ $$->arg2 = $5;
+ }
| INT SYM {
if ($2->class != SYM_VOID) cf_error("Symbol already defined, can not use as variable\n" );
$2->class = SYM_VARIABLE_INT;
printf( "New variable\n" );
$$ = NULL;
}
- | SYM '=' expr {
+ | VAR '(' SYM ')' {
+ $$ = f_new_inst();
+ switch ($3->class) {
+ case SYM_VARIABLE_INT:
+ $$->code = 'i';
+ $$->arg1 = &($3->aux);
+ break;
+ default:
+ cf_error("Can not use this class of symbol as variable" );
+ }
+ }
+ | CONST '(' expr ')' {
+ $$ = f_new_inst();
+ $$->code = 'c';
+ $$->arg1 = $3;
+ }
+ | SYM '=' term {
$$ = f_new_inst();
printf( "Ook, we'll set value\n" );
if ($1->class != SYM_VARIABLE_INT)
@@ -84,13 +118,22 @@ term:
$$->arg1 = $1;
$$->arg2 = $3;
}
- | PRINT '(' SYM ')' {
+ | PRINT '(' term ')' {
$$ = f_new_inst();
printf( "Ook, we'll print something\n" );
$$->code = 'p';
$$->arg1 = $3;
$$->arg2 = NULL;
}
+ | PUTS '(' TEXT ')' {
+ $$ = f_new_inst();
+ $$->code = 'd';
+ $$->arg1 = $3;
+ }
+ | DIE {
+ $$ = f_new_inst();
+ $$->code = '!';
+ }
| PRINTDEBUG {
$$ = f_new_inst();
$$->code = 'D';