Commit 3c8f317d authored by Masahiro Yamada's avatar Masahiro Yamada

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: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
parent a01e5d24
...@@ -15,15 +15,15 @@ static struct kconf_id kconf_id_array[] = { ...@@ -15,15 +15,15 @@ static struct kconf_id kconf_id_array[] = {
{ "endif", T_ENDIF, TF_COMMAND }, { "endif", T_ENDIF, TF_COMMAND },
{ "depends", T_DEPENDS, TF_COMMAND }, { "depends", T_DEPENDS, TF_COMMAND },
{ "optional", T_OPTIONAL, 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 }, { "prompt", T_PROMPT, TF_COMMAND },
{ "tristate", T_TYPE, TF_COMMAND, S_TRISTATE }, { "bool", T_BOOL, TF_COMMAND },
{ "def_tristate", T_DEFAULT, TF_COMMAND, S_TRISTATE }, { "tristate", T_TRISTATE, TF_COMMAND },
{ "bool", T_TYPE, TF_COMMAND, S_BOOLEAN }, { "int", T_INT, TF_COMMAND },
{ "def_bool", T_DEFAULT, TF_COMMAND, S_BOOLEAN }, { "hex", T_HEX, TF_COMMAND },
{ "int", T_TYPE, TF_COMMAND, S_INT }, { "string", T_STRING, TF_COMMAND },
{ "hex", T_TYPE, TF_COMMAND, S_HEX },
{ "string", T_TYPE, TF_COMMAND, S_STRING },
{ "select", T_SELECT, TF_COMMAND }, { "select", T_SELECT, TF_COMMAND },
{ "imply", T_IMPLY, TF_COMMAND }, { "imply", T_IMPLY, TF_COMMAND },
{ "range", T_RANGE, TF_COMMAND }, { "range", T_RANGE, TF_COMMAND },
......
...@@ -50,7 +50,6 @@ struct kconf_id { ...@@ -50,7 +50,6 @@ struct kconf_id {
const char *name; const char *name;
int token; int token;
unsigned int flags; unsigned int flags;
enum symbol_type stype;
}; };
extern int yylineno; extern int yylineno;
......
...@@ -40,6 +40,7 @@ static struct menu *current_menu, *current_entry; ...@@ -40,6 +40,7 @@ static struct menu *current_menu, *current_entry;
struct expr *expr; struct expr *expr;
struct menu *menu; struct menu *menu;
const struct kconf_id *id; const struct kconf_id *id;
enum symbol_type type;
enum variable_flavor flavor; enum variable_flavor flavor;
} }
...@@ -59,8 +60,6 @@ static struct menu *current_menu, *current_entry; ...@@ -59,8 +60,6 @@ static struct menu *current_menu, *current_entry;
%token <id>T_DEPENDS %token <id>T_DEPENDS
%token <id>T_OPTIONAL %token <id>T_OPTIONAL
%token <id>T_PROMPT %token <id>T_PROMPT
%token <id>T_TYPE
%token <id>T_DEFAULT
%token <id>T_SELECT %token <id>T_SELECT
%token <id>T_IMPLY %token <id>T_IMPLY
%token <id>T_RANGE %token <id>T_RANGE
...@@ -69,8 +68,16 @@ static struct menu *current_menu, *current_entry; ...@@ -69,8 +68,16 @@ static struct menu *current_menu, *current_entry;
%token <id>T_ON %token <id>T_ON
%token <string> T_WORD %token <string> T_WORD
%token <string> T_WORD_QUOTE %token <string> T_WORD_QUOTE
%token T_BOOL
%token T_CLOSE_PAREN %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_OPEN_PAREN
%token T_STRING
%token T_TRISTATE
%token T_EOL %token T_EOL
%token <string> T_VARIABLE %token <string> T_VARIABLE
%token <flavor> T_ASSIGN %token <flavor> T_ASSIGN
...@@ -85,6 +92,7 @@ static struct menu *current_menu, *current_entry; ...@@ -85,6 +92,7 @@ static struct menu *current_menu, *current_entry;
%type <string> prompt %type <string> prompt
%type <symbol> nonconst_symbol %type <symbol> nonconst_symbol
%type <symbol> symbol %type <symbol> symbol
%type <type> type logic_type default
%type <expr> expr %type <expr> expr
%type <expr> if_expr %type <expr> if_expr
%type <id> end %type <id> end
...@@ -169,12 +177,12 @@ config_option_list: ...@@ -169,12 +177,12 @@ config_option_list:
| config_option_list help | 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", printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
zconf_curname(), zconf_lineno(), zconf_curname(), zconf_lineno(),
$1->stype); $1);
}; };
config_option: T_PROMPT prompt if_expr T_EOL config_option: T_PROMPT prompt if_expr T_EOL
...@@ -183,14 +191,14 @@ 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()); 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); menu_add_expr(P_DEFAULT, $2, $3);
if ($1->stype != S_UNKNOWN) if ($1 != S_UNKNOWN)
menu_set_type($1->stype); menu_set_type($1);
printd(DEBUG_PARSE, "%s:%d:default(%u)\n", printd(DEBUG_PARSE, "%s:%d:default(%u)\n",
zconf_curname(), zconf_lineno(), zconf_curname(), zconf_lineno(),
$1->stype); $1);
}; };
config_option: T_SELECT nonconst_symbol if_expr T_EOL config_option: T_SELECT nonconst_symbol if_expr T_EOL
...@@ -274,15 +282,11 @@ choice_option: T_PROMPT prompt 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()); 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);
menu_set_type($1->stype);
printd(DEBUG_PARSE, "%s:%d:type(%u)\n", printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
zconf_curname(), zconf_lineno(), zconf_curname(), zconf_lineno(), $1);
$1->stype);
} else
YYERROR;
}; };
choice_option: T_OPTIONAL T_EOL choice_option: T_OPTIONAL T_EOL
...@@ -293,14 +297,26 @@ 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 choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL
{ {
if ($1->stype == S_UNKNOWN) {
menu_add_symbol(P_DEFAULT, $2, $3); menu_add_symbol(P_DEFAULT, $2, $3);
printd(DEBUG_PARSE, "%s:%d:default\n", printd(DEBUG_PARSE, "%s:%d:default\n",
zconf_curname(), zconf_lineno()); zconf_curname(), zconf_lineno());
} else
YYERROR;
}; };
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: choice_block:
/* empty */ /* empty */
| choice_block common_stmt | choice_block common_stmt
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment