diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-01-11 10:50:50 -0500 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-01-21 10:49:31 -0500 |
commit | 765f4cdef6f80d389d14f5f7368b27083a67cafc (patch) | |
tree | 84882d6da95b7c2f6c80d025a6c1930978b261b7 /scripts | |
parent | 84dd95d4f87a0dd2b635df936b1fc27d7424e097 (diff) |
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 <yamada.masahiro@socionext.com>
Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/kconfig/Makefile | 3 | ||||
-rw-r--r-- | scripts/kconfig/zconf.l | 16 | ||||
-rw-r--r-- | scripts/kconfig/zconf.y | 22 |
3 files changed, 19 insertions, 22 deletions
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 61cdc5efb98a..2ad1cf57a55f 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile | |||
@@ -211,9 +211,6 @@ HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) | |||
211 | HOSTCFLAGS_zconf.lex.o := -I$(src) | 211 | HOSTCFLAGS_zconf.lex.o := -I$(src) |
212 | HOSTCFLAGS_zconf.tab.o := -I$(src) | 212 | HOSTCFLAGS_zconf.tab.o := -I$(src) |
213 | 213 | ||
214 | LEX_PREFIX_zconf := zconf | ||
215 | YACC_PREFIX_zconf := zconf | ||
216 | |||
217 | HOSTLOADLIBES_qconf = $(KC_QT_LIBS) | 214 | HOSTLOADLIBES_qconf = $(KC_QT_LIBS) |
218 | HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) | 215 | HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) |
219 | 216 | ||
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index c410d257da06..07e074dc68a1 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
@@ -106,11 +106,11 @@ n [A-Za-z0-9_-] | |||
106 | current_pos.file = current_file; | 106 | current_pos.file = current_file; |
107 | current_pos.lineno = current_file->lineno; | 107 | current_pos.lineno = current_file->lineno; |
108 | if (id && id->flags & TF_COMMAND) { | 108 | if (id && id->flags & TF_COMMAND) { |
109 | zconflval.id = id; | 109 | yylval.id = id; |
110 | return id->token; | 110 | return id->token; |
111 | } | 111 | } |
112 | alloc_string(yytext, yyleng); | 112 | alloc_string(yytext, yyleng); |
113 | zconflval.string = text; | 113 | yylval.string = text; |
114 | return T_WORD; | 114 | return T_WORD; |
115 | } | 115 | } |
116 | . warn_ignored_character(*yytext); | 116 | . warn_ignored_character(*yytext); |
@@ -142,11 +142,11 @@ n [A-Za-z0-9_-] | |||
142 | ({n}|[/.])+ { | 142 | ({n}|[/.])+ { |
143 | const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); | 143 | const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); |
144 | if (id && id->flags & TF_PARAM) { | 144 | if (id && id->flags & TF_PARAM) { |
145 | zconflval.id = id; | 145 | yylval.id = id; |
146 | return id->token; | 146 | return id->token; |
147 | } | 147 | } |
148 | alloc_string(yytext, yyleng); | 148 | alloc_string(yytext, yyleng); |
149 | zconflval.string = text; | 149 | yylval.string = text; |
150 | return T_WORD; | 150 | return T_WORD; |
151 | } | 151 | } |
152 | #.* /* comment */ | 152 | #.* /* comment */ |
@@ -161,7 +161,7 @@ n [A-Za-z0-9_-] | |||
161 | <STRING>{ | 161 | <STRING>{ |
162 | [^'"\\\n]+/\n { | 162 | [^'"\\\n]+/\n { |
163 | append_string(yytext, yyleng); | 163 | append_string(yytext, yyleng); |
164 | zconflval.string = text; | 164 | yylval.string = text; |
165 | return T_WORD_QUOTE; | 165 | return T_WORD_QUOTE; |
166 | } | 166 | } |
167 | [^'"\\\n]+ { | 167 | [^'"\\\n]+ { |
@@ -169,7 +169,7 @@ n [A-Za-z0-9_-] | |||
169 | } | 169 | } |
170 | \\.?/\n { | 170 | \\.?/\n { |
171 | append_string(yytext + 1, yyleng - 1); | 171 | append_string(yytext + 1, yyleng - 1); |
172 | zconflval.string = text; | 172 | yylval.string = text; |
173 | return T_WORD_QUOTE; | 173 | return T_WORD_QUOTE; |
174 | } | 174 | } |
175 | \\.? { | 175 | \\.? { |
@@ -178,7 +178,7 @@ n [A-Za-z0-9_-] | |||
178 | \'|\" { | 178 | \'|\" { |
179 | if (str == yytext[0]) { | 179 | if (str == yytext[0]) { |
180 | BEGIN(PARAM); | 180 | BEGIN(PARAM); |
181 | zconflval.string = text; | 181 | yylval.string = text; |
182 | return T_WORD_QUOTE; | 182 | return T_WORD_QUOTE; |
183 | } else | 183 | } else |
184 | append_string(yytext, 1); | 184 | append_string(yytext, 1); |
@@ -261,7 +261,7 @@ void zconf_starthelp(void) | |||
261 | 261 | ||
262 | static void zconf_endhelp(void) | 262 | static void zconf_endhelp(void) |
263 | { | 263 | { |
264 | zconflval.string = text; | 264 | yylval.string = text; |
265 | BEGIN(INITIAL); | 265 | BEGIN(INITIAL); |
266 | } | 266 | } |
267 | 267 | ||
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index d2964c68f066..21ce883e5d9e 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y | |||
@@ -20,10 +20,10 @@ | |||
20 | 20 | ||
21 | int cdebug = PRINTD; | 21 | int cdebug = PRINTD; |
22 | 22 | ||
23 | extern int zconflex(void); | 23 | int yylex(void); |
24 | static void yyerror(const char *err); | ||
24 | static void zconfprint(const char *err, ...); | 25 | static void zconfprint(const char *err, ...); |
25 | static void zconf_error(const char *err, ...); | 26 | static void zconf_error(const char *err, ...); |
26 | static void zconferror(const char *err); | ||
27 | static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); | 27 | static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); |
28 | 28 | ||
29 | struct symbol *symbol_hash[SYMBOL_HASHSIZE]; | 29 | struct symbol *symbol_hash[SYMBOL_HASHSIZE]; |
@@ -531,9 +531,9 @@ void conf_parse(const char *name) | |||
531 | _menu_init(); | 531 | _menu_init(); |
532 | 532 | ||
533 | if (getenv("ZCONF_DEBUG")) | 533 | if (getenv("ZCONF_DEBUG")) |
534 | zconfdebug = 1; | 534 | yydebug = 1; |
535 | zconfparse(); | 535 | yyparse(); |
536 | if (zconfnerrs) | 536 | if (yynerrs) |
537 | exit(1); | 537 | exit(1); |
538 | if (!modules_sym) | 538 | if (!modules_sym) |
539 | modules_sym = sym_find( "n" ); | 539 | modules_sym = sym_find( "n" ); |
@@ -546,9 +546,9 @@ void conf_parse(const char *name) | |||
546 | menu_finalize(&rootmenu); | 546 | menu_finalize(&rootmenu); |
547 | for_all_symbols(i, sym) { | 547 | for_all_symbols(i, sym) { |
548 | if (sym_check_deps(sym)) | 548 | if (sym_check_deps(sym)) |
549 | zconfnerrs++; | 549 | yynerrs++; |
550 | } | 550 | } |
551 | if (zconfnerrs) | 551 | if (yynerrs) |
552 | exit(1); | 552 | exit(1); |
553 | sym_set_change_count(1); | 553 | sym_set_change_count(1); |
554 | } | 554 | } |
@@ -573,7 +573,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok | |||
573 | if (id->token != endtoken) { | 573 | if (id->token != endtoken) { |
574 | zconf_error("unexpected '%s' within %s block", | 574 | zconf_error("unexpected '%s' within %s block", |
575 | id->name, zconf_tokenname(starttoken)); | 575 | id->name, zconf_tokenname(starttoken)); |
576 | zconfnerrs++; | 576 | yynerrs++; |
577 | return false; | 577 | return false; |
578 | } | 578 | } |
579 | if (current_menu->file != current_file) { | 579 | if (current_menu->file != current_file) { |
@@ -582,7 +582,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok | |||
582 | fprintf(stderr, "%s:%d: location of the '%s'\n", | 582 | fprintf(stderr, "%s:%d: location of the '%s'\n", |
583 | current_menu->file->name, current_menu->lineno, | 583 | current_menu->file->name, current_menu->lineno, |
584 | zconf_tokenname(starttoken)); | 584 | zconf_tokenname(starttoken)); |
585 | zconfnerrs++; | 585 | yynerrs++; |
586 | return false; | 586 | return false; |
587 | } | 587 | } |
588 | return true; | 588 | return true; |
@@ -603,7 +603,7 @@ static void zconf_error(const char *err, ...) | |||
603 | { | 603 | { |
604 | va_list ap; | 604 | va_list ap; |
605 | 605 | ||
606 | zconfnerrs++; | 606 | yynerrs++; |
607 | fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); | 607 | fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); |
608 | va_start(ap, err); | 608 | va_start(ap, err); |
609 | vfprintf(stderr, err, ap); | 609 | vfprintf(stderr, err, ap); |
@@ -611,7 +611,7 @@ static void zconf_error(const char *err, ...) | |||
611 | fprintf(stderr, "\n"); | 611 | fprintf(stderr, "\n"); |
612 | } | 612 | } |
613 | 613 | ||
614 | static void zconferror(const char *err) | 614 | static void yyerror(const char *err) |
615 | { | 615 | { |
616 | fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); | 616 | fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); |
617 | } | 617 | } |