summaryrefslogtreecommitdiffstats
path: root/filter/config.Y
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>1999-01-15 17:49:17 +0100
committerPavel Machek <pavel@ucw.cz>1999-01-15 17:49:17 +0100
commitb9d70dc84e488212328103438bdf4e369c7d27a1 (patch)
tree96afe1e6d460c3ba55b27a92c052800d9616df25 /filter/config.Y
parentb79f9215b99c7a54dbb2639c972dda497d141133 (diff)
downloadbird-b9d70dc84e488212328103438bdf4e369c7d27a1.tar
bird-b9d70dc84e488212328103438bdf4e369c7d27a1.zip
Filters, second try. This time they have their own directory.
Diffstat (limited to 'filter/config.Y')
-rw-r--r--filter/config.Y100
1 files changed, 100 insertions, 0 deletions
diff --git a/filter/config.Y b/filter/config.Y
new file mode 100644
index 0000000..265463d
--- /dev/null
+++ b/filter/config.Y
@@ -0,0 +1,100 @@
+/*
+ * BIRD - filters
+ *
+ * Copyright 1998 Pavel Machek
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+CF_HDR
+
+#include "nest/bird.h"
+#include "filter/filter.h"
+#include "lib/resource.h"
+#include "lib/socket.h"
+#include "lib/timer.h"
+#include "nest/protocol.h"
+#include "nest/iface.h"
+#include "nest/route.h"
+
+CF_DECLS
+
+CF_KEYWORDS(FUNCTION, FILTER, PRINTDEBUG, INT, PRINT)
+
+%type <x> expr
+
+CF_GRAMMAR
+
+config:
+ program {
+ printf( "Wow, we have full program\n" );
+ return 0;
+ }
+ ;
+
+program: /* EMPTY */
+ | program function
+ ;
+
+CF_ADDTO(conf, function)
+function:
+ FUNCTION SYM '(' ')' '{' expr '}' {
+ extern struct f_instruction *last_func;
+ if ($2->class != SYM_VOID) cf_error("Symbol already defined" );
+ $2->class = SYM_FUNCTION;
+ $2->aux = $6;
+ last_func = $6;
+ printf("Hmm, we've got one function here\n");
+ }
+ ;
+
+CF_ADDTO(conf, filter)
+filter:
+ FILTER SYM '{' expr '}' {
+ if ($2->class != SYM_VOID) cf_error("Symbol already defined" );
+ $2->class = SYM_FILTER;
+ $2->aux = $4;
+ printf( "We have new filter defined (%s)\n", $2->name )
+ }
+ ;
+
+/* Programs */
+
+expr: /* EMPTY */ { $$ = NULL; }
+ | expr ';' expr {
+ $$ = cfg_alloc(sizeof(struct f_instruction));
+ printf( "We've got statement here\n" );
+ $$->code = ',';
+ $$->arg1 = $1;
+ $$->arg2 = $3;
+ }
+ | 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 '=' cexpr {
+ $$ = cfg_alloc(sizeof(struct f_instruction));
+ printf( "Ook, we'll set value\n" );
+ if ($1->class != SYM_VARIABLE_INT)
+ cf_error( "You may only set variables\n" );
+ $$->code = '=';
+ $$->arg1 = $1;
+ $$->arg2 = $3;
+ }
+ | PRINT '(' SYM ')' {
+ $$ = cfg_alloc(sizeof(struct f_instruction));
+ printf( "Ook, we'll print something\n" );
+ $$->code = 'p';
+ $$->arg1 = $3;
+ $$->arg2 = NULL;
+ }
+ | PRINTDEBUG {
+ $$ = cfg_alloc(sizeof(struct f_instruction));
+ $$->code = 'D';
+ $$->arg1 = $$->arg2 = NULL;
+ }
+ ;
+
+CF_END