diff options
author | Maria Matejka <mq@ucw.cz> | 2019-05-17 22:18:49 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2019-05-17 22:26:21 +0200 |
commit | 9eef9c648cee7179e069ea1f978d4e86cef580d3 (patch) | |
tree | 3fc43a6feeb005116c62d92905302734e37bb472 /conf/cf-lex.l | |
parent | fe503c7c0632b385222c92b85d04526fdf36a1a3 (diff) |
Lexer now returns known sym / unknown sym / keyword
Diffstat (limited to 'conf/cf-lex.l')
-rw-r--r-- | conf/cf-lex.l | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/conf/cf-lex.l b/conf/cf-lex.l index 4f69993e..83e4e77c 100644 --- a/conf/cf-lex.l +++ b/conf/cf-lex.l @@ -654,6 +654,14 @@ cf_default_name(char *template, int *counter) static enum yytokentype cf_lex_symbol(const char *data) { + /* Have we defined such a symbol? */ + struct symbol *sym = cf_get_symbol(data); + cf_lval.s = sym; + + if (sym->class != SYM_VOID) + return CF_SYM_KNOWN; + + /* Is it a keyword? */ struct keyword *k = HASH_FIND(kw_hash, KW, data); if (k) { @@ -666,19 +674,9 @@ cf_lex_symbol(const char *data) } } - cf_lval.s = cf_get_symbol(data); - switch (cf_lval.s->class) { - case SYM_VOID: return CF_SYM_VOID; - case SYM_PROTO: return CF_SYM_PROTO; - case SYM_TEMPLATE: return CF_SYM_TEMPLATE; - case SYM_FUNCTION: return CF_SYM_FUNCTION; - case SYM_FILTER: return CF_SYM_FILTER; - case SYM_TABLE: return CF_SYM_TABLE; - case SYM_ATTRIBUTE: return CF_SYM_ATTRIBUTE; - case SYM_VARIABLE_RANGE: return CF_SYM_VARIABLE; - case SYM_CONSTANT_RANGE: return CF_SYM_CONSTANT; - default: bug("Unknown symbol class %d", cf_lval.s->class); - } + /* OK, undefined symbol */ + cf_lval.s = sym; + return CF_SYM_UNDEFINED; } static void |