diff options
author | Maria Matejka <mq@ucw.cz> | 2023-06-13 09:39:29 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2023-09-12 15:47:24 +0200 |
commit | f86c86b7913f55c1221d8c5e1ff27700aa663a6e (patch) | |
tree | fb57686f11636843e22f2ae4966a5884df3eb807 /conf/cf-lex.l | |
parent | 6b95353ebdaa724252492f941ebe75f80e9e545a (diff) |
Filter/Conf: Method names have their own keyword hash
To allow for future dynamic method definition, parsing method names is
done via a dedicated keyword hash/scope.
Diffstat (limited to 'conf/cf-lex.l')
-rw-r--r-- | conf/cf-lex.l | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/conf/cf-lex.l b/conf/cf-lex.l index 8dc0ac89..9e52417a 100644 --- a/conf/cf-lex.l +++ b/conf/cf-lex.l @@ -54,6 +54,7 @@ struct keyword { byte *name; int value; + enum keyword_scope scope; }; #include "conf/keywords.h" @@ -707,16 +708,17 @@ cf_lex_init(int is_cli, struct config *c) { global_root_scope_pool = rp_new(&root_pool, "Keywords pool"); linpool *kwlp = lp_new(global_root_scope_pool); - global_root_scope = lp_allocz(kwlp, sizeof(*global_root_scope)); + global_root_scope = lp_allocz(kwlp, sizeof(*global_root_scope) * CFK__MAX); for (const struct keyword *k = keyword_list; k->name; k++) { - struct symbol *sym = cf_new_symbol(global_root_scope, global_root_scope_pool, kwlp, k->name); + struct symbol *sym = cf_new_symbol(&global_root_scope[k->scope], global_root_scope_pool, kwlp, k->name); sym->class = SYM_KEYWORD; sym->keyword = k; } - global_root_scope->readonly = 1; + for (int s = 0; s < CFK__MAX; s++) + global_root_scope[s].readonly = 1; } ifs_head = ifs = push_ifs(NULL); @@ -740,7 +742,7 @@ cf_lex_init(int is_cli, struct config *c) if (is_cli) c->current_scope->next = config->root_scope; else - c->current_scope->next = global_root_scope; + c->current_scope->next = &global_root_scope[CFK_KEYWORDS]; } /** |