X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=scripts%2Fconfig%2Fzconf.y;h=d9a9f62cb016d9c06ba2dd3af5aabce3ca93f523;hb=fc9465348aae4b95c22c5cc4475833fa36b60ab1;hp=4b8ba45061b1b879f2dfee20acb6e6742c4fb826;hpb=2cd10271b8414588da9e37793eb25ad182683cb8;p=openwrt.git diff --git a/scripts/config/zconf.y b/scripts/config/zconf.y index 4b8ba45061..d9a9f62cb0 100644 --- a/scripts/config/zconf.y +++ b/scripts/config/zconf.y @@ -11,11 +11,8 @@ #include #include -#define LKC_DIRECT_LINK #include "lkc.h" -#include "zconf.hash.c" - #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) #define PRINTD 0x0001 @@ -27,18 +24,14 @@ extern int zconflex(void); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); static void zconferror(const char *err); -static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken); +static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); -struct symbol *symbol_hash[257]; +struct symbol *symbol_hash[SYMBOL_HASHSIZE]; static struct menu *current_menu, *current_entry; -#define YYDEBUG 0 -#if YYDEBUG -#define YYERROR_VERBOSE -#endif %} -%expect 26 +%expect 30 %union { @@ -47,7 +40,7 @@ static struct menu *current_menu, *current_entry; struct symbol *symbol; struct expr *expr; struct menu *menu; - struct kconf_id *id; + const struct kconf_id *id; } %token T_MAINMENU @@ -64,13 +57,14 @@ static struct menu *current_menu, *current_entry; %token T_IF %token T_ENDIF %token T_DEPENDS -%token T_REQUIRES %token T_OPTIONAL %token T_PROMPT %token T_TYPE %token T_DEFAULT %token T_SELECT %token T_RANGE +%token T_VISIBLE +%token T_OPTION %token T_ON %token T_RESET %token T_WORD @@ -92,6 +86,7 @@ static struct menu *current_menu, *current_entry; %type end %type option_name %type if_entry menu_entry choice_entry +%type symbol_option_arg word_opt %destructor { fprintf(stderr, "%s:%d: missing end statement for this entry\n", @@ -100,15 +95,21 @@ static struct menu *current_menu, *current_entry; menu_end_menu(); } if_entry menu_entry choice_entry +%{ +/* Include zconf.hash.c here so it can see the token constants. */ +#include "zconf.hash.c" +%} + %% -input: stmt_list; +input: nl start | start; + +start: mainmenu_stmt stmt_list | stmt_list; stmt_list: /* empty */ | stmt_list common_stmt | stmt_list choice_stmt | stmt_list menu_stmt - | stmt_list T_MAINMENU prompt nl | stmt_list end { zconf_error("unexpected end statement"); } | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); } | stmt_list option_name error T_EOL @@ -119,7 +120,7 @@ stmt_list: ; option_name: - T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT | T_RESET + T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE | T_RESET ; common_stmt: @@ -174,6 +175,7 @@ menuconfig_stmt: menuconfig_entry_start config_option_list config_option_list: /* empty */ | config_option_list config_option + | config_option_list symbol_option | config_option_list depends | config_option_list help | config_option_list option_error @@ -216,12 +218,32 @@ config_option: T_RANGE symbol symbol if_expr T_EOL printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); }; +symbol_option: T_OPTION symbol_option_list T_EOL +; + +symbol_option_list: + /* empty */ + | symbol_option_list T_WORD symbol_option_arg +{ + const struct kconf_id *id = kconf_id_lookup($2, strlen($2)); + if (id && id->flags & TF_OPTION) + menu_add_option(id->token, $3); + else + zconfprint("warning: ignoring unknown option %s", $2); + free($2); +}; + +symbol_option_arg: + /* empty */ { $$ = NULL; } + | T_EQUAL prompt { $$ = $2; } +; + /* choice entry */ -choice: T_CHOICE T_EOL +choice: T_CHOICE word_opt T_EOL { - struct symbol *sym = sym_lookup(NULL, 0); - sym->flags |= SYMBOL_CHOICE; + struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE); + sym->flags |= SYMBOL_AUTO; menu_add_entry(sym); menu_add_expr(P_CHOICE, NULL, NULL); printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); @@ -323,6 +345,13 @@ if_block: | if_block choice_stmt ; +/* mainmenu entry */ + +mainmenu_stmt: T_MAINMENU prompt nl +{ + menu_add_prompt(P_MENU, $2, NULL); +}; + /* menu entry */ menu: T_MENU prompt T_EOL @@ -332,7 +361,7 @@ menu: T_MENU prompt T_EOL printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); }; -menu_entry: menu depends_list +menu_entry: menu visibility_list depends_list { $$ = menu_add_menu(); }; @@ -385,7 +414,7 @@ help_start: T_HELP T_EOL help: help_start T_HELPTEXT { - current_entry->sym->help = $2; + current_entry->help = $2; }; /* depends option */ @@ -401,16 +430,23 @@ depends: T_DEPENDS T_ON expr T_EOL { menu_add_dep($3); printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); -} - | T_DEPENDS expr T_EOL +} | T_DEPENDS expr T_EOL { menu_add_dep($2); - printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno()); -} - | T_REQUIRES expr T_EOL + zconfprint("warning: deprecated 'depends' syntax, use 'depends on' instead."); +}; + +/* visibility option */ + +visibility_list: + /* empty */ + | visibility_list visible + | visibility_list T_EOL +; + +visible: T_VISIBLE if_expr { - menu_add_dep($2); - printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno()); + menu_add_visibility($2); }; /* prompt statement */ @@ -450,9 +486,12 @@ expr: symbol { $$ = expr_alloc_symbol($1); } ; symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); } - | T_WORD_QUOTE { $$ = sym_lookup($1, 1); free($1); } + | T_WORD_QUOTE { $$ = sym_lookup($1, SYMBOL_CONST); free($1); } ; +word_opt: /* empty */ { $$ = NULL; } + | T_WORD + %% void conf_parse(const char *name) @@ -463,9 +502,11 @@ void conf_parse(const char *name) zconf_initscan(name); sym_init(); - menu_init(); - modules_sym = sym_lookup("MODULES", 0); - rootmenu.prompt = menu_add_prompt(P_MENU, "OpenWrt Configuration", NULL); + _menu_init(); + modules_sym = sym_lookup(NULL, 0); + modules_sym->type = S_BOOLEAN; + modules_sym->flags |= SYMBOL_AUTO; + rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); #if YYDEBUG if (getenv("ZCONF_DEBUG")) @@ -474,15 +515,27 @@ void conf_parse(const char *name) zconfparse(); if (zconfnerrs) exit(1); + if (!modules_sym->prop) { + struct property *prop; + + prop = prop_alloc(P_DEFAULT, modules_sym); + prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0)); + } + + rootmenu.prompt->text = _(rootmenu.prompt->text); + rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text); + menu_finalize(&rootmenu); for_all_symbols(i, sym) { - sym_check_deps(sym); + if (sym_check_deps(sym)) + zconfnerrs++; } - - sym_change_count = 1; + if (zconfnerrs) + exit(1); + sym_set_change_count(1); } -const char *zconf_tokenname(int token) +static const char *zconf_tokenname(int token) { switch (token) { case T_MENU: return "menu"; @@ -492,11 +545,12 @@ const char *zconf_tokenname(int token) case T_IF: return "if"; case T_ENDIF: return "endif"; case T_DEPENDS: return "depends"; + case T_VISIBLE: return "visible"; } return ""; } -static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken) +static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken) { if (id->token != endtoken) { zconf_error("unexpected '%s' within %s block", @@ -541,12 +595,10 @@ static void zconf_error(const char *err, ...) static void zconferror(const char *err) { -#if YYDEBUG fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); -#endif } -void print_quoted_string(FILE *out, const char *str) +static void print_quoted_string(FILE *out, const char *str) { const char *p; int len; @@ -563,15 +615,15 @@ void print_quoted_string(FILE *out, const char *str) putc('"', out); } -void print_symbol(FILE *out, struct menu *menu) +static void print_symbol(FILE *out, struct menu *menu) { struct symbol *sym = menu->sym; struct property *prop; if (sym_is_choice(sym)) - fprintf(out, "choice\n"); + fprintf(out, "\nchoice\n"); else - fprintf(out, "config %s\n", sym->name); + fprintf(out, "\nconfig %s\n", sym->name); switch (sym->type) { case S_BOOLEAN: fputs(" boolean\n", out); @@ -617,18 +669,32 @@ void print_symbol(FILE *out, struct menu *menu) case P_CHOICE: fputs(" #choice value\n", out); break; + case P_SELECT: + fputs( " select ", out); + expr_fprint(prop->expr, out); + fputc('\n', out); + break; + case P_RANGE: + fputs( " range ", out); + expr_fprint(prop->expr, out); + fputc('\n', out); + break; + case P_MENU: + fputs( " menu ", out); + print_quoted_string(out, prop->text); + fputc('\n', out); + break; default: fprintf(out, " unknown prop %d!\n", prop->type); break; } } - if (sym->help) { - int len = strlen(sym->help); - while (sym->help[--len] == '\n') - sym->help[len] = 0; - fprintf(out, " help\n%s\n", sym->help); + if (menu->help) { + int len = strlen(menu->help); + while (menu->help[--len] == '\n') + menu->help[len] = 0; + fprintf(out, " help\n%s\n", menu->help); } - fputc('\n', out); } void zconfdump(FILE *out) @@ -661,7 +727,6 @@ void zconfdump(FILE *out) expr_fprint(prop->visible.expr, out); fputc('\n', out); } - fputs("\n", out); } if (menu->list) @@ -679,7 +744,7 @@ void zconfdump(FILE *out) } } -#include "lex.zconf.c" +#include "zconf.lex.c" #include "util.c" #include "confdata.c" #include "expr.c"