diff options
author | Maria Matejka <mq@ucw.cz> | 2022-05-04 12:24:30 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2022-05-04 15:39:21 +0200 |
commit | cce974e8ea992d0e6d2f649eca7880b436d91d71 (patch) | |
tree | 64448636b2633ef429923eb3f9625b11e03f2b4a /conf/cf-lex.l | |
parent | 8ebac84bc8d51e2404ce6d6dc5e35fb261830596 (diff) |
Conf: Allowing keyword redefinition
Some tokens are both keywords and symbols. For now, we allow only
specific keywords to be redefined; in future, more of the keywords may
be added to this category.
The redefinable keywords must be specified in any .Y file as follows:
toksym: THE_KEYWORD ;
See proto/bgp/config.Y for an example.
Also dropped a lot of unused terminals.
Diffstat (limited to 'conf/cf-lex.l')
-rw-r--r-- | conf/cf-lex.l | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/conf/cf-lex.l b/conf/cf-lex.l index e84e1d9d..11bcdb18 100644 --- a/conf/cf-lex.l +++ b/conf/cf-lex.l @@ -709,10 +709,7 @@ cf_lex_symbol(const char *data) struct symbol *sym = cf_get_symbol(data); cf_lval.s = sym; - if (sym->class != SYM_VOID) - return CF_SYM_KNOWN; - - /* Is it a keyword? */ + /* Is it a keyword? Prefer the keyword. */ struct keyword *k = HASH_FIND(kw_hash, KW, data); if (k) { @@ -725,9 +722,11 @@ cf_lex_symbol(const char *data) } } - /* OK, undefined symbol */ - cf_lval.s = sym; - return CF_SYM_UNDEFINED; + /* OK, only a symbol. */ + if (sym->class == SYM_VOID) + return CF_SYM_UNDEFINED; + else + return CF_SYM_KNOWN; } static void |