diff options
author | Martin Mares <mj@ucw.cz> | 1999-11-15 11:35:41 +0000 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 1999-11-15 11:35:41 +0000 |
commit | 944f008af7a46144e38f963097e8e4cce493e2a7 (patch) | |
tree | b6821d20d592a846477dccef76608f7c135bab5a /conf | |
parent | cbc31830079fb5e49c14c3de446b10ed8da99ce0 (diff) |
Defined CF_ENUM.
Diffstat (limited to 'conf')
-rw-r--r-- | conf/cf-lex.l | 14 | ||||
-rw-r--r-- | conf/confbase.Y | 2 | ||||
-rw-r--r-- | conf/gen_keywords.m4 | 5 | ||||
-rw-r--r-- | conf/gen_parser.m4 | 3 |
4 files changed, 20 insertions, 4 deletions
diff --git a/conf/cf-lex.l b/conf/cf-lex.l index 797dbeac..5959e701 100644 --- a/conf/cf-lex.l +++ b/conf/cf-lex.l @@ -9,14 +9,14 @@ %{ #undef REJECT /* Avoid name clashes */ -#include "filter/filter.h" - #include <errno.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include "nest/bird.h" +#include "nest/route.h" +#include "filter/filter.h" #include "conf/conf.h" #include "conf/cf-parse.tab.h" @@ -119,7 +119,15 @@ WHITE [ \t] while (k) { if (!strcmp(k->name, yytext)) - return k->value; + { + if (k->value > 0) + return k->value; + else + { + cf_lval.i = -k->value; + return ENUM; + } + } k=k->next; } cf_lval.s = cf_find_sym(yytext, h); diff --git a/conf/confbase.Y b/conf/confbase.Y index 0ec74538..bf4ed331 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -38,7 +38,7 @@ CF_DECLS } %token END CLI_MARKER -%token <i> NUM +%token <i> NUM ENUM %token <i32> RTRID %token <a> IPA %token <s> SYM diff --git a/conf/gen_keywords.m4 b/conf/gen_keywords.m4 index 37b882b5..1c77cd5c 100644 --- a/conf/gen_keywords.m4 +++ b/conf/gen_keywords.m4 @@ -22,6 +22,11 @@ m4_define(CF_KEYWORDS, `m4_define([[CF_toks]],[[]])CF_iterate([[CF_keywd]], [[$@ m4_define(CF_CLI, `CF_KEYWORDS(m4_translit($1, [[ ]], [[,]])) ') +# Enums are translated to C initializers: use CF_ENUM(typename, prefix, values) +m4_define(CF_enum, `m4_divert(0){ "CF_enum_prefix[[]]$1", -((CF_enum_type<<16) | CF_enum_prefix[[]]$1) }, +m4_divert(-1)') +m4_define(CF_ENUM, `m4_define([[CF_enum_type]],$1)m4_define([[CF_enum_prefix]],$2)CF_iterate([[CF_enum]], [[m4_shift(m4_shift($@))]])DNL') + # As we are processing C source, we must access all M4 primitives via # m4_* and also set different quoting convention: `[[' and ']]' m4_changequote([[,]]) diff --git a/conf/gen_parser.m4 b/conf/gen_parser.m4 index 8441c83b..d38df21e 100644 --- a/conf/gen_parser.m4 +++ b/conf/gen_parser.m4 @@ -44,6 +44,9 @@ m4_divert(2)CF_KEYWORDS(m4_translit($1, [[ ]], [[,]])) m4_divert(3)CF_ADDTO(cli_cmd, CF_cmd) CF_cmd: $1 ') +# ENUM declarations are ignored +m4_define(CF_ENUM, `') + # After all configuration templates end, we finally generate the grammar file. m4_m4wrap(` m4_divert(0)DNL |