diff options
author | Martin Mares <mj@ucw.cz> | 1999-05-17 20:06:19 +0000 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 1999-05-17 20:06:19 +0000 |
commit | 4107df1d1b7454a16e6f45ea55aae13b01c9f566 (patch) | |
tree | 633f4f7a266cb62d0aea1a08d6f2d7538573e8cc /filter | |
parent | b23c5e0ff4e9071b2568bf2f7d437bc13273d17d (diff) |
Implemented two new symbol handling functions:
o cf_define_symbol() -- it assigns a meaning to a symbol, bailing
out if it already has one.
o cf_find_symbol() -- finds symbol by name and creates it if not found.
Also modified filter/config.Y to make use of the first function.
Diffstat (limited to 'filter')
-rw-r--r-- | filter/config.Y | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/filter/config.Y b/filter/config.Y index 4fd18157..c7f20148 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -40,9 +40,7 @@ CF_GRAMMAR CF_ADDTO(conf, filter_def) filter_def: FILTER SYM filter_body { - if ($2->class != SYM_VOID) cf_error("Symbol already defined" ); - $2->class = SYM_FILTER; - $2->def = $3; + cf_define_symbol($2, SYM_FILTER, $3); $3->name = $2->name; printf( "We have new filter defined (%s)\n", $2->name ) } @@ -67,8 +65,7 @@ type: decls: /* EMPTY */ | type SYM ';' decls { - if ($2->class != SYM_VOID) cf_error("Symbol already defined, can not use as variable\n" ); - $2->class = SYM_VARIABLE | $1; + cf_define_symbol($2, SYM_VARIABLE | $1, NULL); printf( "New variable %s type %x\n", $2->name, $1 ); } ; @@ -104,9 +101,7 @@ CF_ADDTO(conf, function_def) function_def: FUNCTION SYM function_params function_body { extern struct f_inst *startup_func; - if ($2->class != SYM_VOID) cf_error("Symbol already defined" ); - $2->class = SYM_FUNCTION; - $2->def = $4; + cf_define_symbol($2, SYM_FUNCTION, $4); if (!strcasecmp($2->name, "startup")) startup_func = $4; printf("Hmm, we've got one function here - %s\n", $2->name); |