From 3dc782557da1337d56609efe08d2000ea41f9890 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 12 Jan 2018 00:50:50 +0900 Subject: [PATCH] kconfig: use default 'yy' prefix for lexer and parser Flex and Bison provide an option to change the prefix of globally- visible symbols. This is useful to link multiple lexers and/or parsers into the same executable. However, Kconfig (and any other host programs in kernel) uses a single lexer and parser. I do not see a good reason to change the default 'yy' prefix. Signed-off-by: Masahiro Yamada Reviewed-by: Ulf Magnusson Signed-off-by: Christian Lamparter --- config/zconf.l | 16 ++++++++-------- config/zconf.y | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/config/zconf.l b/config/zconf.l index 9720530..3200318 100644 --- a/config/zconf.l +++ b/config/zconf.l @@ -106,11 +106,11 @@ n [A-Za-z0-9_-] current_pos.file = current_file; current_pos.lineno = current_file->lineno; if (id && id->flags & TF_COMMAND) { - zconflval.id = id; + yylval.id = id; return id->token; } alloc_string(yytext, yyleng); - zconflval.string = text; + yylval.string = text; return T_WORD; } . warn_ignored_character(*yytext); @@ -142,11 +142,11 @@ n [A-Za-z0-9_-] ({n}|[/.])+ { const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); if (id && id->flags & TF_PARAM) { - zconflval.id = id; + yylval.id = id; return id->token; } alloc_string(yytext, yyleng); - zconflval.string = text; + yylval.string = text; return T_WORD; } #.* /* comment */ @@ -161,7 +161,7 @@ n [A-Za-z0-9_-] { [^'"\\\n]+/\n { append_string(yytext, yyleng); - zconflval.string = text; + yylval.string = text; return T_WORD_QUOTE; } [^'"\\\n]+ { @@ -169,7 +169,7 @@ n [A-Za-z0-9_-] } \\.?/\n { append_string(yytext + 1, yyleng - 1); - zconflval.string = text; + yylval.string = text; return T_WORD_QUOTE; } \\.? { @@ -178,7 +178,7 @@ n [A-Za-z0-9_-] \'|\" { if (str == yytext[0]) { BEGIN(PARAM); - zconflval.string = text; + yylval.string = text; return T_WORD_QUOTE; } else append_string(yytext, 1); @@ -261,7 +261,7 @@ void zconf_starthelp(void) static void zconf_endhelp(void) { - zconflval.string = text; + yylval.string = text; BEGIN(INITIAL); } diff --git a/config/zconf.y b/config/zconf.y index 4dad8e5..1aa9859 100644 --- a/config/zconf.y +++ b/config/zconf.y @@ -20,10 +20,10 @@ int cdebug = PRINTD; -extern int zconflex(void); +int yylex(void); +static void yyerror(const char *err); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); -static void zconferror(const char *err); static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); struct symbol *symbol_hash[SYMBOL_HASHSIZE]; @@ -532,9 +532,9 @@ void conf_parse(const char *name) rootmenu.prompt = menu_add_prompt(P_MENU, "CARL9170 Firmware Configuration", NULL); if (getenv("ZCONF_DEBUG")) - zconfdebug = 1; - zconfparse(); - if (zconfnerrs) + yydebug = 1; + yyparse(); + if (yynerrs) exit(1); if (!modules_sym) modules_sym = sym_find( "n" ); @@ -547,9 +547,9 @@ void conf_parse(const char *name) menu_finalize(&rootmenu); for_all_symbols(i, sym) { if (sym_check_deps(sym)) - zconfnerrs++; + yynerrs++; } - if (zconfnerrs) + if (yynerrs) exit(1); sym_set_change_count(1); } @@ -574,7 +574,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok if (id->token != endtoken) { zconf_error("unexpected '%s' within %s block", id->name, zconf_tokenname(starttoken)); - zconfnerrs++; + yynerrs++; return false; } if (current_menu->file != current_file) { @@ -583,7 +583,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok fprintf(stderr, "%s:%d: location of the '%s'\n", current_menu->file->name, current_menu->lineno, zconf_tokenname(starttoken)); - zconfnerrs++; + yynerrs++; return false; } return true; @@ -604,7 +604,7 @@ static void zconf_error(const char *err, ...) { va_list ap; - zconfnerrs++; + yynerrs++; fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); va_start(ap, err); vfprintf(stderr, err, ap); @@ -612,7 +612,7 @@ static void zconf_error(const char *err, ...) fprintf(stderr, "\n"); } -static void zconferror(const char *err) +static void yyerror(const char *err) { fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); } -- 2.31.1