Skip to content

Commit

Permalink
[PATCH] kconfig: simplify symbol type parsing
Browse files Browse the repository at this point in the history
This simplifies the parser a bit by merging the various symbol types into a
single token and adds the type to the keyword hash.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Roman Zippel authored and Linus Torvalds committed Nov 9, 2005
1 parent 7a88488 commit 3370f9f
Show file tree
Hide file tree
Showing 7 changed files with 342 additions and 447 deletions.
5 changes: 4 additions & 1 deletion scripts/kconfig/lex.zconf.c_shipped
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,7 @@ YY_RULE_SETUP
struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
if (id && id->flags & TF_COMMAND) {
BEGIN(PARAM);
zconflval.id = id;
return id->token;
}
alloc_string(zconftext, zconfleng);
Expand Down Expand Up @@ -1091,8 +1092,10 @@ case 19:
YY_RULE_SETUP
{
struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
if (id && id->flags & TF_PARAM)
if (id && id->flags & TF_PARAM) {
zconflval.id = id;
return id->token;
}
alloc_string(zconftext, zconfleng);
zconflval.string = text;
return T_WORD;
Expand Down
1 change: 1 addition & 0 deletions scripts/kconfig/lkc.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct kconf_id {
int name;
int token;
unsigned int flags;
enum symbol_type stype;
};

int zconfparse(void);
Expand Down
20 changes: 10 additions & 10 deletions scripts/kconfig/zconf.gperf
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ endif, T_ENDIF, TF_COMMAND
depends, T_DEPENDS, TF_COMMAND
requires, T_REQUIRES, TF_COMMAND
optional, T_OPTIONAL, TF_COMMAND
default, T_DEFAULT, TF_COMMAND
default, T_DEFAULT, TF_COMMAND, S_UNKNOWN
prompt, T_PROMPT, TF_COMMAND
tristate, T_TRISTATE, TF_COMMAND
def_tristate, T_DEF_TRISTATE, TF_COMMAND
bool, T_BOOLEAN, TF_COMMAND
boolean, T_BOOLEAN, TF_COMMAND
def_bool, T_DEF_BOOLEAN, TF_COMMAND
def_boolean, T_DEF_BOOLEAN, TF_COMMAND
int, T_INT, TF_COMMAND
hex, T_HEX, TF_COMMAND
string, T_STRING, TF_COMMAND
tristate, T_TYPE, TF_COMMAND, S_TRISTATE
def_tristate, T_DEFAULT, TF_COMMAND, S_TRISTATE
bool, T_TYPE, TF_COMMAND, S_BOOLEAN
boolean, T_TYPE, TF_COMMAND, S_BOOLEAN
def_bool, T_DEFAULT, TF_COMMAND, S_BOOLEAN
def_boolean, 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
select, T_SELECT, TF_COMMAND
enable, T_SELECT, TF_COMMAND
range, T_RANGE, TF_COMMAND
Expand Down
20 changes: 10 additions & 10 deletions scripts/kconfig/zconf.hash.c_shipped
Original file line number Diff line number Diff line change
Expand Up @@ -172,27 +172,27 @@ kconf_id_lookup (register const char *str, register unsigned int len)
{
{-1}, {-1},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_IF, TF_COMMAND|TF_PARAM},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_INT, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_TYPE, TF_COMMAND, S_INT},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str4, T_HELP, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5, T_ENDIF, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str6, T_SELECT, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_ENDMENU, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_TRISTATE, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_TYPE, TF_COMMAND, S_TRISTATE},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str9, T_ENDCHOICE, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str10, T_RANGE, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str11, T_STRING, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEF_BOOLEAN, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str11, T_TYPE, TF_COMMAND, S_STRING},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_MENU, TF_COMMAND},
{-1},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_DEF_BOOLEAN, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEF_TRISTATE, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_DEFAULT, TF_COMMAND, S_BOOLEAN},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_MAINMENU, TF_COMMAND},
{-1},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str20, T_MENUCONFIG, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_CONFIG, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_ON, TF_PARAM},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_HEX, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_HEX},
{-1}, {-1},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26, T_SOURCE, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_DEPENDS, TF_COMMAND},
Expand All @@ -201,9 +201,9 @@ kconf_id_lookup (register const char *str, register unsigned int len)
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SELECT, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_REQUIRES, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str34, T_BOOLEAN, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str34, T_TYPE, TF_COMMAND, S_BOOLEAN},
{-1}, {-1},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_BOOLEAN, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_TYPE, TF_COMMAND, S_BOOLEAN},
{-1}, {-1}, {-1},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_CHOICE, TF_COMMAND},
{-1}, {-1}, {-1}, {-1},
Expand Down
5 changes: 4 additions & 1 deletion scripts/kconfig/zconf.l
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ n [A-Za-z0-9_]
struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
if (id && id->flags & TF_COMMAND) {
BEGIN(PARAM);
zconflval.id = id;
return id->token;
}
alloc_string(yytext, yyleng);
Expand Down Expand Up @@ -117,8 +118,10 @@ n [A-Za-z0-9_]
--- /* ignore */
({n}|[-/.])+ {
struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
if (id && id->flags & TF_PARAM)
if (id && id->flags & TF_PARAM) {
zconflval.id = id;
return id->token;
}
alloc_string(yytext, yyleng);
zconflval.string = text;
return T_WORD;
Expand Down
Loading

0 comments on commit 3370f9f

Please sign in to comment.