Skip to content

Commit 3c8f317

Browse files
committed
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 <yamada.masahiro@socionext.com>
1 parent a01e5d2 commit 3c8f317

3 files changed

Lines changed: 47 additions & 32 deletions

File tree

‎scripts/kconfig/kconf_id.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ static struct kconf_id kconf_id_array[] = {
1515
{ "endif", T_ENDIF, TF_COMMAND },
1616
{ "depends", T_DEPENDS, TF_COMMAND },
1717
{ "optional", T_OPTIONAL, TF_COMMAND },
18-
{ "default", T_DEFAULT, TF_COMMAND, S_UNKNOWN },
18+
{ "default", T_DEFAULT, TF_COMMAND },
19+
{ "def_bool", T_DEF_BOOL, TF_COMMAND },
20+
{ "def_tristate", T_DEF_TRISTATE, TF_COMMAND },
1921
{ "prompt", T_PROMPT, TF_COMMAND },
20-
{ "tristate", T_TYPE, TF_COMMAND, S_TRISTATE },
21-
{ "def_tristate", T_DEFAULT, TF_COMMAND, S_TRISTATE },
22-
{ "bool", T_TYPE, TF_COMMAND, S_BOOLEAN },
23-
{ "def_bool", T_DEFAULT, TF_COMMAND, S_BOOLEAN },
24-
{ "int", T_TYPE, TF_COMMAND, S_INT },
25-
{ "hex", T_TYPE, TF_COMMAND, S_HEX },
26-
{ "string", T_TYPE, TF_COMMAND, S_STRING },
22+
{ "bool", T_BOOL, TF_COMMAND },
23+
{ "tristate", T_TRISTATE, TF_COMMAND },
24+
{ "int", T_INT, TF_COMMAND },
25+
{ "hex", T_HEX, TF_COMMAND },
26+
{ "string", T_STRING, TF_COMMAND },
2727
{ "select", T_SELECT, TF_COMMAND },
2828
{ "imply", T_IMPLY, TF_COMMAND },
2929
{ "range", T_RANGE, TF_COMMAND },

‎scripts/kconfig/lkc.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ struct kconf_id {
5050
const char *name;
5151
int token;
5252
unsigned int flags;
53-
enum symbol_type stype;
5453
};
5554

5655
extern int yylineno;

‎scripts/kconfig/zconf.y‎

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ static struct menu *current_menu, *current_entry;
4040
struct expr *expr;
4141
struct menu *menu;
4242
const struct kconf_id *id;
43+
enum symbol_type type;
4344
enum variable_flavor flavor;
4445
}
4546

@@ -59,8 +60,6 @@ static struct menu *current_menu, *current_entry;
5960
%token <id>T_DEPENDS
6061
%token <id>T_OPTIONAL
6162
%token <id>T_PROMPT
62-
%token <id>T_TYPE
63-
%token <id>T_DEFAULT
6463
%token <id>T_SELECT
6564
%token <id>T_IMPLY
6665
%token <id>T_RANGE
@@ -69,8 +68,16 @@ static struct menu *current_menu, *current_entry;
6968
%token <id>T_ON
7069
%token <string> T_WORD
7170
%token <string> T_WORD_QUOTE
71+
%token T_BOOL
7272
%token T_CLOSE_PAREN
73+
%token T_DEFAULT
74+
%token T_DEF_BOOL
75+
%token T_DEF_TRISTATE
76+
%token T_HEX
77+
%token T_INT
7378
%token T_OPEN_PAREN
79+
%token T_STRING
80+
%token T_TRISTATE
7481
%token T_EOL
7582
%token <string> T_VARIABLE
7683
%token <flavor> T_ASSIGN
@@ -85,6 +92,7 @@ static struct menu *current_menu, *current_entry;
8592
%type <string> prompt
8693
%type <symbol> nonconst_symbol
8794
%type <symbol> symbol
95+
%type <type> type logic_type default
8896
%type <expr> expr
8997
%type <expr> if_expr
9098
%type <id> end
@@ -169,12 +177,12 @@ config_option_list:
169177
| config_option_list help
170178
;
171179

172-
config_option: T_TYPE prompt_stmt_opt T_EOL
180+
config_option: type prompt_stmt_opt T_EOL
173181
{
174-
menu_set_type($1->stype);
182+
menu_set_type($1);
175183
printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
176184
zconf_curname(), zconf_lineno(),
177-
$1->stype);
185+
$1);
178186
};
179187

180188
config_option: T_PROMPT prompt if_expr T_EOL
@@ -183,14 +191,14 @@ config_option: T_PROMPT prompt if_expr T_EOL
183191
printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
184192
};
185193

186-
config_option: T_DEFAULT expr if_expr T_EOL
194+
config_option: default expr if_expr T_EOL
187195
{
188196
menu_add_expr(P_DEFAULT, $2, $3);
189-
if ($1->stype != S_UNKNOWN)
190-
menu_set_type($1->stype);
197+
if ($1 != S_UNKNOWN)
198+
menu_set_type($1);
191199
printd(DEBUG_PARSE, "%s:%d:default(%u)\n",
192200
zconf_curname(), zconf_lineno(),
193-
$1->stype);
201+
$1);
194202
};
195203

196204
config_option: T_SELECT nonconst_symbol if_expr T_EOL
@@ -274,15 +282,11 @@ choice_option: T_PROMPT prompt if_expr T_EOL
274282
printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
275283
};
276284

277-
choice_option: T_TYPE prompt_stmt_opt T_EOL
285+
choice_option: logic_type prompt_stmt_opt T_EOL
278286
{
279-
if ($1->stype == S_BOOLEAN || $1->stype == S_TRISTATE) {
280-
menu_set_type($1->stype);
281-
printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
282-
zconf_curname(), zconf_lineno(),
283-
$1->stype);
284-
} else
285-
YYERROR;
287+
menu_set_type($1);
288+
printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
289+
zconf_curname(), zconf_lineno(), $1);
286290
};
287291

288292
choice_option: T_OPTIONAL T_EOL
@@ -293,14 +297,26 @@ choice_option: T_OPTIONAL T_EOL
293297

294298
choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL
295299
{
296-
if ($1->stype == S_UNKNOWN) {
297-
menu_add_symbol(P_DEFAULT, $2, $3);
298-
printd(DEBUG_PARSE, "%s:%d:default\n",
299-
zconf_curname(), zconf_lineno());
300-
} else
301-
YYERROR;
300+
menu_add_symbol(P_DEFAULT, $2, $3);
301+
printd(DEBUG_PARSE, "%s:%d:default\n",
302+
zconf_curname(), zconf_lineno());
302303
};
303304

305+
type:
306+
logic_type
307+
| T_INT { $$ = S_INT; }
308+
| T_HEX { $$ = S_HEX; }
309+
| T_STRING { $$ = S_STRING; }
310+
311+
logic_type:
312+
T_BOOL { $$ = S_BOOLEAN; }
313+
| T_TRISTATE { $$ = S_TRISTATE; }
314+
315+
default:
316+
T_DEFAULT { $$ = S_UNKNOWN; }
317+
| T_DEF_BOOL { $$ = S_BOOLEAN; }
318+
| T_DEF_TRISTATE { $$ = S_TRISTATE; }
319+
304320
choice_block:
305321
/* empty */
306322
| choice_block common_stmt

0 commit comments

Comments
 (0)