From: Masahiro Yamada Date: Tue, 11 Dec 2018 11:00:59 +0000 (+0900) Subject: kconfig: use distinct tokens for type and default properties X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=89d9fc0b2c28b1699ebfaeacde69aad688a2893a;p=carl9170fw.git kconfig: use distinct tokens for type and default properties This commit removes kconf_id::stype to prepare for the entire removal of kconf_id.c To simplify the lexer, I want keywords straight-mapped to tokens. Signed-off-by: Masahiro Yamada Signed-off-by: Christian Lamparter --- diff --git a/config/kconf_id.c b/config/kconf_id.c index b3e0ea0..ec2c011 100644 --- a/config/kconf_id.c +++ b/config/kconf_id.c @@ -15,15 +15,15 @@ static struct kconf_id kconf_id_array[] = { { "endif", T_ENDIF, TF_COMMAND }, { "depends", T_DEPENDS, TF_COMMAND }, { "optional", T_OPTIONAL, TF_COMMAND }, - { "default", T_DEFAULT, TF_COMMAND, S_UNKNOWN }, + { "default", T_DEFAULT, TF_COMMAND }, + { "def_bool", T_DEF_BOOL, TF_COMMAND }, + { "def_tristate", T_DEF_TRISTATE, TF_COMMAND }, { "prompt", T_PROMPT, TF_COMMAND }, - { "tristate", T_TYPE, TF_COMMAND, S_TRISTATE }, - { "def_tristate", T_DEFAULT, TF_COMMAND, S_TRISTATE }, - { "bool", T_TYPE, TF_COMMAND, S_BOOLEAN }, - { "def_bool", T_DEFAULT, TF_COMMAND, S_BOOLEAN }, - { "int", T_TYPE, TF_COMMAND, S_INT }, - { "hex", T_TYPE, TF_COMMAND, S_HEX }, - { "string", T_TYPE, TF_COMMAND, S_STRING }, + { "bool", T_BOOL, TF_COMMAND }, + { "tristate", T_TRISTATE, TF_COMMAND }, + { "int", T_INT, TF_COMMAND }, + { "hex", T_HEX, TF_COMMAND }, + { "string", T_STRING, TF_COMMAND }, { "select", T_SELECT, TF_COMMAND }, { "imply", T_IMPLY, TF_COMMAND }, { "range", T_RANGE, TF_COMMAND }, diff --git a/config/lkc.h b/config/lkc.h index 9eb7c83..b6bbcd1 100644 --- a/config/lkc.h +++ b/config/lkc.h @@ -50,7 +50,6 @@ struct kconf_id { const char *name; int token; unsigned int flags; - enum symbol_type stype; }; extern int yylineno; diff --git a/config/zconf.y b/config/zconf.y index 1dac176..de3b94e 100644 --- a/config/zconf.y +++ b/config/zconf.y @@ -40,6 +40,7 @@ static struct menu *current_menu, *current_entry; struct expr *expr; struct menu *menu; const struct kconf_id *id; + enum symbol_type type; enum variable_flavor flavor; } @@ -59,8 +60,6 @@ static struct menu *current_menu, *current_entry; %token T_DEPENDS %token T_OPTIONAL %token T_PROMPT -%token T_TYPE -%token T_DEFAULT %token T_SELECT %token T_IMPLY %token T_RANGE @@ -69,8 +68,16 @@ static struct menu *current_menu, *current_entry; %token T_ON %token T_WORD %token T_WORD_QUOTE +%token T_BOOL %token T_CLOSE_PAREN +%token T_DEFAULT +%token T_DEF_BOOL +%token T_DEF_TRISTATE +%token T_HEX +%token T_INT %token T_OPEN_PAREN +%token T_STRING +%token T_TRISTATE %token T_EOL %token T_VARIABLE %token T_ASSIGN @@ -85,6 +92,7 @@ static struct menu *current_menu, *current_entry; %type prompt %type nonconst_symbol %type symbol +%type type logic_type default %type expr %type if_expr %type end @@ -169,12 +177,12 @@ config_option_list: | config_option_list help ; -config_option: T_TYPE prompt_stmt_opt T_EOL +config_option: type prompt_stmt_opt T_EOL { - menu_set_type($1->stype); + menu_set_type($1); printd(DEBUG_PARSE, "%s:%d:type(%u)\n", zconf_curname(), zconf_lineno(), - $1->stype); + $1); }; config_option: T_PROMPT prompt if_expr T_EOL @@ -183,14 +191,14 @@ config_option: T_PROMPT prompt if_expr T_EOL printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); }; -config_option: T_DEFAULT expr if_expr T_EOL +config_option: default expr if_expr T_EOL { menu_add_expr(P_DEFAULT, $2, $3); - if ($1->stype != S_UNKNOWN) - menu_set_type($1->stype); + if ($1 != S_UNKNOWN) + menu_set_type($1); printd(DEBUG_PARSE, "%s:%d:default(%u)\n", zconf_curname(), zconf_lineno(), - $1->stype); + $1); }; config_option: T_SELECT nonconst_symbol if_expr T_EOL @@ -274,15 +282,11 @@ choice_option: T_PROMPT prompt if_expr T_EOL printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); }; -choice_option: T_TYPE prompt_stmt_opt T_EOL +choice_option: logic_type prompt_stmt_opt T_EOL { - if ($1->stype == S_BOOLEAN || $1->stype == S_TRISTATE) { - menu_set_type($1->stype); - printd(DEBUG_PARSE, "%s:%d:type(%u)\n", - zconf_curname(), zconf_lineno(), - $1->stype); - } else - YYERROR; + menu_set_type($1); + printd(DEBUG_PARSE, "%s:%d:type(%u)\n", + zconf_curname(), zconf_lineno(), $1); }; choice_option: T_OPTIONAL T_EOL @@ -293,14 +297,26 @@ choice_option: T_OPTIONAL T_EOL choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL { - if ($1->stype == S_UNKNOWN) { - menu_add_symbol(P_DEFAULT, $2, $3); - printd(DEBUG_PARSE, "%s:%d:default\n", - zconf_curname(), zconf_lineno()); - } else - YYERROR; + menu_add_symbol(P_DEFAULT, $2, $3); + printd(DEBUG_PARSE, "%s:%d:default\n", + zconf_curname(), zconf_lineno()); }; +type: + logic_type + | T_INT { $$ = S_INT; } + | T_HEX { $$ = S_HEX; } + | T_STRING { $$ = S_STRING; } + +logic_type: + T_BOOL { $$ = S_BOOLEAN; } + | T_TRISTATE { $$ = S_TRISTATE; } + +default: + T_DEFAULT { $$ = S_UNKNOWN; } + | T_DEF_BOOL { $$ = S_BOOLEAN; } + | T_DEF_TRISTATE { $$ = S_TRISTATE; } + choice_block: /* empty */ | choice_block common_stmt