-rw-r--r-- | scripts/kconfig/zconf.y | 230 |
1 files changed, 134 insertions, 96 deletions
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 996b10a..2468068 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y | |||
@@ -29,3 +29,3 @@ struct symbol *symbol_hash[257]; | |||
29 | %} | 29 | %} |
30 | %expect 36 | 30 | %expect 40 |
31 | 31 | ||
@@ -48,2 +48,3 @@ struct symbol *symbol_hash[257]; | |||
48 | %token T_CONFIG | 48 | %token T_CONFIG |
49 | %token T_MENUCONFIG | ||
49 | %token T_HELP | 50 | %token T_HELP |
@@ -58,3 +59,6 @@ struct symbol *symbol_hash[257]; | |||
58 | %token T_TRISTATE | 59 | %token T_TRISTATE |
60 | %token T_DEF_TRISTATE | ||
59 | %token T_BOOLEAN | 61 | %token T_BOOLEAN |
62 | %token T_DEF_BOOLEAN | ||
63 | %token T_STRING | ||
60 | %token T_INT | 64 | %token T_INT |
@@ -62,3 +66,3 @@ struct symbol *symbol_hash[257]; | |||
62 | %token <string> T_WORD | 66 | %token <string> T_WORD |
63 | %token <string> T_STRING | 67 | %token <string> T_WORD_QUOTE |
64 | %token T_UNEQUAL | 68 | %token T_UNEQUAL |
@@ -69,2 +73,4 @@ struct symbol *symbol_hash[257]; | |||
69 | %token T_ON | 73 | %token T_ON |
74 | %token T_SELECT | ||
75 | %token T_RANGE | ||
70 | 76 | ||
@@ -105,2 +111,3 @@ common_block: | |||
105 | | config_stmt | 111 | | config_stmt |
112 | | menuconfig_stmt | ||
106 | | source_stmt | 113 | | source_stmt |
@@ -110,5 +117,5 @@ common_block: | |||
110 | 117 | ||
111 | /* config entry */ | 118 | /* config/menuconfig entry */ |
112 | 119 | ||
113 | config_entry_start: T_CONFIG T_WORD | 120 | config_entry_start: T_CONFIG T_WORD T_EOL |
114 | { | 121 | { |
@@ -120,3 +127,3 @@ config_entry_start: T_CONFIG T_WORD | |||
120 | 127 | ||
121 | config_stmt: config_entry_start T_EOL config_option_list | 128 | config_stmt: config_entry_start config_option_list |
122 | { | 129 | { |
@@ -126,11 +133,29 @@ config_stmt: config_entry_start T_EOL config_option_list | |||
126 | 133 | ||
134 | menuconfig_entry_start: T_MENUCONFIG T_WORD T_EOL | ||
135 | { | ||
136 | struct symbol *sym = sym_lookup($2, 0); | ||
137 | sym->flags |= SYMBOL_OPTIONAL; | ||
138 | menu_add_entry(sym); | ||
139 | printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2); | ||
140 | }; | ||
141 | |||
142 | menuconfig_stmt: menuconfig_entry_start config_option_list | ||
143 | { | ||
144 | if (current_entry->prompt) | ||
145 | current_entry->prompt->type = P_MENU; | ||
146 | else | ||
147 | zconfprint("warning: menuconfig statement without prompt"); | ||
148 | menu_end_entry(); | ||
149 | printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); | ||
150 | }; | ||
151 | |||
127 | config_option_list: | 152 | config_option_list: |
128 | /* empty */ | 153 | /* empty */ |
129 | | config_option_list config_option T_EOL | 154 | | config_option_list config_option |
130 | | config_option_list depends T_EOL | 155 | | config_option_list depends |
131 | | config_option_list help | 156 | | config_option_list help |
132 | | config_option_list T_EOL | 157 | | config_option_list T_EOL |
133 | { }; | 158 | ; |
134 | 159 | ||
135 | config_option: T_TRISTATE prompt_stmt_opt | 160 | config_option: T_TRISTATE prompt_stmt_opt T_EOL |
136 | { | 161 | { |
@@ -140,3 +165,10 @@ config_option: T_TRISTATE prompt_stmt_opt | |||
140 | 165 | ||
141 | config_option: T_BOOLEAN prompt_stmt_opt | 166 | config_option: T_DEF_TRISTATE expr if_expr T_EOL |
167 | { | ||
168 | menu_add_expr(P_DEFAULT, $2, $3); | ||
169 | menu_set_type(S_TRISTATE); | ||
170 | printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); | ||
171 | }; | ||
172 | |||
173 | config_option: T_BOOLEAN prompt_stmt_opt T_EOL | ||
142 | { | 174 | { |
@@ -146,3 +178,10 @@ config_option: T_BOOLEAN prompt_stmt_opt | |||
146 | 178 | ||
147 | config_option: T_INT prompt_stmt_opt | 179 | config_option: T_DEF_BOOLEAN expr if_expr T_EOL |
180 | { | ||
181 | menu_add_expr(P_DEFAULT, $2, $3); | ||
182 | menu_set_type(S_BOOLEAN); | ||
183 | printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); | ||
184 | }; | ||
185 | |||
186 | config_option: T_INT prompt_stmt_opt T_EOL | ||
148 | { | 187 | { |
@@ -152,3 +191,3 @@ config_option: T_INT prompt_stmt_opt | |||
152 | 191 | ||
153 | config_option: T_HEX prompt_stmt_opt | 192 | config_option: T_HEX prompt_stmt_opt T_EOL |
154 | { | 193 | { |
@@ -158,3 +197,3 @@ config_option: T_HEX prompt_stmt_opt | |||
158 | 197 | ||
159 | config_option: T_STRING prompt_stmt_opt | 198 | config_option: T_STRING prompt_stmt_opt T_EOL |
160 | { | 199 | { |
@@ -164,5 +203,5 @@ config_option: T_STRING prompt_stmt_opt | |||
164 | 203 | ||
165 | config_option: T_PROMPT prompt if_expr | 204 | config_option: T_PROMPT prompt if_expr T_EOL |
166 | { | 205 | { |
167 | menu_add_prop(P_PROMPT, $2, NULL, $3); | 206 | menu_add_prompt(P_PROMPT, $2, $3); |
168 | printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); | 207 | printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); |
@@ -170,5 +209,5 @@ config_option: T_PROMPT prompt if_expr | |||
170 | 209 | ||
171 | config_option: T_DEFAULT symbol if_expr | 210 | config_option: T_DEFAULT expr if_expr T_EOL |
172 | { | 211 | { |
173 | menu_add_prop(P_DEFAULT, NULL, $2, $3); | 212 | menu_add_expr(P_DEFAULT, $2, $3); |
174 | printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); | 213 | printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); |
@@ -176,5 +215,17 @@ config_option: T_DEFAULT symbol if_expr | |||
176 | 215 | ||
216 | config_option: T_SELECT T_WORD if_expr T_EOL | ||
217 | { | ||
218 | menu_add_symbol(P_SELECT, sym_lookup($2, 0), $3); | ||
219 | printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); | ||
220 | }; | ||
221 | |||
222 | config_option: T_RANGE symbol symbol if_expr T_EOL | ||
223 | { | ||
224 | menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4); | ||
225 | printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); | ||
226 | }; | ||
227 | |||
177 | /* choice entry */ | 228 | /* choice entry */ |
178 | 229 | ||
179 | choice: T_CHOICE | 230 | choice: T_CHOICE T_EOL |
180 | { | 231 | { |
@@ -183,3 +234,3 @@ choice: T_CHOICE | |||
183 | menu_add_entry(sym); | 234 | menu_add_entry(sym); |
184 | menu_add_prop(P_CHOICE, NULL, NULL, NULL); | 235 | menu_add_expr(P_CHOICE, NULL, NULL); |
185 | printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); | 236 | printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); |
@@ -187,3 +238,3 @@ choice: T_CHOICE | |||
187 | 238 | ||
188 | choice_entry: choice T_EOL choice_option_list | 239 | choice_entry: choice choice_option_list |
189 | { | 240 | { |
@@ -202,3 +253,3 @@ choice_end: end | |||
202 | choice_stmt: | 253 | choice_stmt: |
203 | choice_entry choice_block choice_end T_EOL | 254 | choice_entry choice_block choice_end |
204 | | choice_entry choice_block | 255 | | choice_entry choice_block |
@@ -211,4 +262,4 @@ choice_option_list: | |||
211 | /* empty */ | 262 | /* empty */ |
212 | | choice_option_list choice_option T_EOL | 263 | | choice_option_list choice_option |
213 | | choice_option_list depends T_EOL | 264 | | choice_option_list depends |
214 | | choice_option_list help | 265 | | choice_option_list help |
@@ -217,5 +268,5 @@ choice_option_list: | |||
217 | 268 | ||
218 | choice_option: T_PROMPT prompt if_expr | 269 | choice_option: T_PROMPT prompt if_expr T_EOL |
219 | { | 270 | { |
220 | menu_add_prop(P_PROMPT, $2, NULL, $3); | 271 | menu_add_prompt(P_PROMPT, $2, $3); |
221 | printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); | 272 | printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); |
@@ -223,3 +274,15 @@ choice_option: T_PROMPT prompt if_expr | |||
223 | 274 | ||
224 | choice_option: T_OPTIONAL | 275 | choice_option: T_TRISTATE prompt_stmt_opt T_EOL |
276 | { | ||
277 | menu_set_type(S_TRISTATE); | ||
278 | printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); | ||
279 | }; | ||
280 | |||
281 | choice_option: T_BOOLEAN prompt_stmt_opt T_EOL | ||
282 | { | ||
283 | menu_set_type(S_BOOLEAN); | ||
284 | printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); | ||
285 | }; | ||
286 | |||
287 | choice_option: T_OPTIONAL T_EOL | ||
225 | { | 288 | { |
@@ -229,5 +292,5 @@ choice_option: T_OPTIONAL | |||
229 | 292 | ||
230 | choice_option: T_DEFAULT symbol if_expr | 293 | choice_option: T_DEFAULT T_WORD if_expr T_EOL |
231 | { | 294 | { |
232 | menu_add_prop(P_DEFAULT, NULL, $2, $3); | 295 | menu_add_symbol(P_DEFAULT, sym_lookup($2, 0), $3); |
233 | printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); | 296 | printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); |
@@ -242,3 +305,3 @@ choice_block: | |||
242 | 305 | ||
243 | if: T_IF expr | 306 | if: T_IF expr T_EOL |
244 | { | 307 | { |
@@ -260,4 +323,4 @@ if_end: end | |||
260 | if_stmt: | 323 | if_stmt: |
261 | if T_EOL if_block if_end T_EOL | 324 | if if_block if_end |
262 | | if T_EOL if_block | 325 | | if if_block |
263 | { | 326 | { |
@@ -276,3 +339,3 @@ if_block: | |||
276 | 339 | ||
277 | menu: T_MENU prompt | 340 | menu: T_MENU prompt T_EOL |
278 | { | 341 | { |
@@ -283,3 +346,3 @@ menu: T_MENU prompt | |||
283 | 346 | ||
284 | menu_entry: menu T_EOL depends_list | 347 | menu_entry: menu depends_list |
285 | { | 348 | { |
@@ -298,3 +361,3 @@ menu_end: end | |||
298 | menu_stmt: | 361 | menu_stmt: |
299 | menu_entry menu_block menu_end T_EOL | 362 | menu_entry menu_block menu_end |
300 | | menu_entry menu_block | 363 | | menu_entry menu_block |
@@ -313,3 +376,3 @@ menu_block: | |||
313 | 376 | ||
314 | source: T_SOURCE prompt | 377 | source: T_SOURCE prompt T_EOL |
315 | { | 378 | { |
@@ -319,3 +382,3 @@ source: T_SOURCE prompt | |||
319 | 382 | ||
320 | source_stmt: source T_EOL | 383 | source_stmt: source |
321 | { | 384 | { |
@@ -326,3 +389,3 @@ source_stmt: source T_EOL | |||
326 | 389 | ||
327 | comment: T_COMMENT prompt | 390 | comment: T_COMMENT prompt T_EOL |
328 | { | 391 | { |
@@ -333,3 +396,3 @@ comment: T_COMMENT prompt | |||
333 | 396 | ||
334 | comment_stmt: comment T_EOL depends_list | 397 | comment_stmt: comment depends_list |
335 | { | 398 | { |
@@ -354,7 +417,7 @@ help: help_start T_HELPTEXT | |||
354 | depends_list: /* empty */ | 417 | depends_list: /* empty */ |
355 | | depends_list depends T_EOL | 418 | | depends_list depends |
356 | | depends_list T_EOL | 419 | | depends_list T_EOL |
357 | { }; | 420 | ; |
358 | 421 | ||
359 | depends: T_DEPENDS T_ON expr | 422 | depends: T_DEPENDS T_ON expr T_EOL |
360 | { | 423 | { |
@@ -363,3 +426,3 @@ depends: T_DEPENDS T_ON expr | |||
363 | } | 426 | } |
364 | | T_DEPENDS expr | 427 | | T_DEPENDS expr T_EOL |
365 | { | 428 | { |
@@ -368,3 +431,3 @@ depends: T_DEPENDS T_ON expr | |||
368 | } | 431 | } |
369 | | T_REQUIRES expr | 432 | | T_REQUIRES expr T_EOL |
370 | { | 433 | { |
@@ -378,9 +441,5 @@ prompt_stmt_opt: | |||
378 | /* empty */ | 441 | /* empty */ |
379 | | prompt | 442 | | prompt if_expr |
380 | { | ||
381 | menu_add_prop(P_PROMPT, $1, NULL, NULL); | ||
382 | } | ||
383 | | prompt T_IF expr | ||
384 | { | 443 | { |
385 | menu_add_prop(P_PROMPT, $1, NULL, $3); | 444 | menu_add_prop(P_PROMPT, $1, NULL, $2); |
386 | }; | 445 | }; |
@@ -388,8 +447,8 @@ prompt_stmt_opt: | |||
388 | prompt: T_WORD | 447 | prompt: T_WORD |
389 | | T_STRING | 448 | | T_WORD_QUOTE |
390 | ; | 449 | ; |
391 | 450 | ||
392 | end: T_ENDMENU { $$ = T_ENDMENU; } | 451 | end: T_ENDMENU nl_or_eof{ $$ = T_ENDMENU; } |
393 | | T_ENDCHOICE { $$ = T_ENDCHOICE; } | 452 | | T_ENDCHOICE nl_or_eof{ $$ = T_ENDCHOICE; } |
394 | | T_ENDIF { $$ = T_ENDIF; } | 453 | | T_ENDIF nl_or_eof{ $$ = T_ENDIF; } |
395 | ; | 454 | ; |
@@ -413,3 +472,3 @@ expr: symbol { $$ = expr_alloc_symbol($1); } | |||
413 | symbol: T_WORD{ $$ = sym_lookup($1, 0); free($1); } | 472 | symbol: T_WORD{ $$ = sym_lookup($1, 0); free($1); } |
414 | | T_STRING{ $$ = sym_lookup($1, 1); free($1); } | 473 | | T_WORD_QUOTE{ $$ = sym_lookup($1, 1); free($1); } |
415 | ; | 474 | ; |
@@ -420,2 +479,5 @@ void conf_parse(const char *name) | |||
420 | { | 479 | { |
480 | struct symbol *sym; | ||
481 | int i; | ||
482 | |||
421 | zconf_initscan(name); | 483 | zconf_initscan(name); |
@@ -424,3 +486,4 @@ void conf_parse(const char *name) | |||
424 | menu_init(); | 486 | menu_init(); |
425 | rootmenu.prompt = menu_add_prop(P_MENU, "Configuration", NULL, NULL); | 487 | modules_sym = sym_lookup("MODULES", 0); |
488 | rootmenu.prompt = menu_add_prop(P_MENU, "Build Configuration", NULL, NULL); | ||
426 | 489 | ||
@@ -431,4 +494,8 @@ void conf_parse(const char *name) | |||
431 | menu_finalize(&rootmenu); | 494 | menu_finalize(&rootmenu); |
432 | 495 | for_all_symbols(i, sym) { | |
433 | modules_sym = sym_lookup("MODULES", 0); | 496 | if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym)) |
497 | printf("\n"); | ||
498 | else | ||
499 | sym->flags |= SYMBOL_CHECK_DONE; | ||
500 | } | ||
434 | 501 | ||
@@ -448,3 +515,3 @@ const char *zconf_tokenname(int token) | |||
448 | return "<token>"; | 515 | return "<token>"; |
449 | } | 516 | } |
450 | 517 | ||
@@ -470,3 +537,3 @@ static void zconfprint(const char *err, ...) | |||
470 | 537 | ||
471 | fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); | 538 | fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno() + 1); |
472 | va_start(ap, err); | 539 | va_start(ap, err); |
@@ -479,3 +546,3 @@ static void zconferror(const char *err) | |||
479 | { | 546 | { |
480 | fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno(), err); | 547 | fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); |
481 | } | 548 | } |
@@ -504,4 +571,2 @@ void print_symbol(FILE *out, struct menu *menu) | |||
504 | 571 | ||
505 | //sym->flags |= SYMBOL_PRINTED; | ||
506 | |||
507 | if (sym_is_choice(sym)) | 572 | if (sym_is_choice(sym)) |
@@ -530,9 +595,2 @@ void print_symbol(FILE *out, struct menu *menu) | |||
530 | } | 595 | } |
531 | #if 0 | ||
532 | if (!expr_is_yes(sym->dep)) { | ||
533 | fputs(" depends ", out); | ||
534 | expr_fprint(sym->dep, out); | ||
535 | fputc('\n', out); | ||
536 | } | ||
537 | #endif | ||
538 | for (prop = sym->prop; prop; prop = prop->next) { | 596 | for (prop = sym->prop; prop; prop = prop->next) { |
@@ -544,12 +602,5 @@ void print_symbol(FILE *out, struct menu *menu) | |||
544 | print_quoted_string(out, prop->text); | 602 | print_quoted_string(out, prop->text); |
545 | if (prop->def) { | 603 | if (!expr_is_yes(prop->visible.expr)) { |
546 | fputc(' ', out); | ||
547 | if (prop->def->flags & SYMBOL_CONST) | ||
548 | print_quoted_string(out, prop->def->name); | ||
549 | else | ||
550 | fputs(prop->def->name, out); | ||
551 | } | ||
552 | if (!expr_is_yes(E_EXPR(prop->visible))) { | ||
553 | fputs(" if ", out); | 604 | fputs(" if ", out); |
554 | expr_fprint(E_EXPR(prop->visible), out); | 605 | expr_fprint(prop->visible.expr, out); |
555 | } | 606 | } |
@@ -559,6 +610,6 @@ void print_symbol(FILE *out, struct menu *menu) | |||
559 | fputs( " default ", out); | 610 | fputs( " default ", out); |
560 | print_quoted_string(out, prop->def->name); | 611 | expr_fprint(prop->expr, out); |
561 | if (!expr_is_yes(E_EXPR(prop->visible))) { | 612 | if (!expr_is_yes(prop->visible.expr)) { |
562 | fputs(" if ", out); | 613 | fputs(" if ", out); |
563 | expr_fprint(E_EXPR(prop->visible), out); | 614 | expr_fprint(prop->visible.expr, out); |
564 | } | 615 | } |
@@ -585,3 +636,2 @@ void zconfdump(FILE *out) | |||
585 | { | 636 | { |
586 | //struct file *file; | ||
587 | struct property *prop; | 637 | struct property *prop; |
@@ -596,7 +646,2 @@ void zconfdump(FILE *out) | |||
596 | switch (prop->type) { | 646 | switch (prop->type) { |
597 | //case T_MAINMENU: | ||
598 | //fputs("\nmainmenu ", out); | ||
599 | //print_quoted_string(out, prop->text); | ||
600 | //fputs("\n", out); | ||
601 | //break; | ||
602 | case P_COMMENT: | 647 | case P_COMMENT: |
@@ -611,9 +656,2 @@ void zconfdump(FILE *out) | |||
611 | break; | 656 | break; |
612 | //case T_SOURCE: | ||
613 | //fputs("\nsource ", out); | ||
614 | //print_quoted_string(out, prop->text); | ||
615 | //fputs("\n", out); | ||
616 | //break; | ||
617 | //case T_IF: | ||
618 | //fputs("\nif\n", out); | ||
619 | default: | 657 | default: |
@@ -621,5 +659,5 @@ void zconfdump(FILE *out) | |||
621 | } | 659 | } |
622 | if (!expr_is_yes(E_EXPR(prop->visible))) { | 660 | if (!expr_is_yes(prop->visible.expr)) { |
623 | fputs(" depends ", out); | 661 | fputs(" depends ", out); |
624 | expr_fprint(E_EXPR(prop->visible), out); | 662 | expr_fprint(prop->visible.expr, out); |
625 | fputc('\n', out); | 663 | fputc('\n', out); |