All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: linux-kbuild@vger.kernel.org
Cc: Ulf Magnusson <ulfalizer@gmail.com>,
	linux-kernel@vger.kernel.org,
	Masahiro Yamada <yamada.masahiro@socionext.com>
Subject: [PATCH 27/27] kconfig: remove keyword lookup table entirely
Date: Tue, 11 Dec 2018 20:01:10 +0900	[thread overview]
Message-ID: <1544526070-16690-28-git-send-email-yamada.masahiro@socionext.com> (raw)
In-Reply-To: <1544526070-16690-1-git-send-email-yamada.masahiro@socionext.com>

Commit 7a88488bbc23 ("[PATCH] kconfig: use gperf for kconfig keywords")
introduced gperf for the keyword lookup.

Then, commit bb3290d91695 ("Remove gperf usage from toolchain") killed
the gperf use. As a result, the linear keyword search was left.

If we do not use gperf, there is no reason to have the separate table
of the keywords. Move all keywords back to the lexer.

I also refactored the lexer to remove the COMMAND and PARAM states.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 scripts/kconfig/kconf_id.c |  49 ---------------
 scripts/kconfig/lkc.h      |   9 ---
 scripts/kconfig/zconf.l    | 153 ++++++++++++++++++++-------------------------
 scripts/kconfig/zconf.y    |   5 --
 4 files changed, 69 insertions(+), 147 deletions(-)
 delete mode 100644 scripts/kconfig/kconf_id.c

diff --git a/scripts/kconfig/kconf_id.c b/scripts/kconfig/kconf_id.c
deleted file mode 100644
index f8b222c..0000000
--- a/scripts/kconfig/kconf_id.c
+++ /dev/null
@@ -1,49 +0,0 @@
-
-static struct kconf_id kconf_id_array[] = {
-	{ "mainmenu",		T_MAINMENU,		TF_COMMAND },
-	{ "menu",		T_MENU,			TF_COMMAND },
-	{ "endmenu",		T_ENDMENU,		TF_COMMAND },
-	{ "source",		T_SOURCE,		TF_COMMAND },
-	{ "choice",		T_CHOICE,		TF_COMMAND },
-	{ "endchoice",		T_ENDCHOICE,		TF_COMMAND },
-	{ "comment",		T_COMMENT,		TF_COMMAND },
-	{ "config",		T_CONFIG,		TF_COMMAND },
-	{ "menuconfig",		T_MENUCONFIG,		TF_COMMAND },
-	{ "help",		T_HELP,			TF_COMMAND },
-	{ "---help---",		T_HELP,			TF_COMMAND },
-	{ "if",			T_IF,			TF_COMMAND|TF_PARAM },
-	{ "endif",		T_ENDIF,		TF_COMMAND },
-	{ "depends",		T_DEPENDS,		TF_COMMAND },
-	{ "optional",		T_OPTIONAL,		TF_COMMAND },
-	{ "default",		T_DEFAULT,		TF_COMMAND },
-	{ "def_bool",		T_DEF_BOOL,		TF_COMMAND },
-	{ "def_tristate",	T_DEF_TRISTATE,		TF_COMMAND },
-	{ "prompt",		T_PROMPT,		TF_COMMAND },
-	{ "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 },
-	{ "visible",		T_VISIBLE,		TF_COMMAND },
-	{ "option",		T_OPTION,		TF_COMMAND },
-	{ "on",			T_ON,			TF_PARAM },
-};
-
-#define KCONF_ID_ARRAY_SIZE (sizeof(kconf_id_array)/sizeof(struct kconf_id))
-
-static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len)
-{
-	int i;
-
-	for (i = 0; i < KCONF_ID_ARRAY_SIZE; i++) {
-		struct kconf_id *id = kconf_id_array+i;
-		int l = strlen(id->name);
-
-		if (len == l && !memcmp(str, id->name, len))
-			return id;
-	}
-	return NULL;
-}
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 5f4880a..ff6b3e4 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -30,9 +30,6 @@ static inline const char *CONFIG_prefix(void)
 #undef CONFIG_
 #define CONFIG_ CONFIG_prefix()
 
-#define TF_COMMAND	0x0001
-#define TF_PARAM	0x0002
-
 enum conf_def_mode {
 	def_default,
 	def_yes,
@@ -41,12 +38,6 @@ enum conf_def_mode {
 	def_random
 };
 
-struct kconf_id {
-	const char *name;
-	int token;
-	unsigned int flags;
-};
-
 extern int yylineno;
 void zconfdump(FILE *out);
 void zconf_starthelp(void);
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index f0734abe..690108f 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -1,6 +1,6 @@
 %option nostdinit noyywrap never-interactive full ecs
 %option 8bit nodefault yylineno
-%x COMMAND HELP STRING PARAM ASSIGN_VAL
+%x ASSIGN_VAL HELP STRING
 %{
 /*
  * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
@@ -94,45 +94,73 @@ n	[A-Za-z0-9_-]
 	int str = 0;
 	int ts, i;
 
-[ \t]*#.*\n	|
-[ \t]*\n	{
-	return T_EOL;
-}
-[ \t]*#.*
-.	{
-	unput(yytext[0]);
-	BEGIN(COMMAND);
-}
-
-
-<COMMAND>{
-	{n}+	{
-		const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
-		if (id && id->flags & TF_COMMAND) {
-			BEGIN(PARAM);
-			return id->token;
-		}
-		alloc_string(yytext, yyleng);
-		yylval.string = text;
-		return T_WORD;
-	}
-	({n}|$)+	{
-		/* this token includes at least one '$' */
-		yylval.string = expand_token(yytext, yyleng);
-		if (strlen(yylval.string))
-			return T_WORD;
-		free(yylval.string);
-	}
-	"="	return T_EQUAL;
-	":="	return T_COLON_EQUAL;
-	"+="	return T_PLUS_EQUAL;
-	[[:blank:]]+
-	.	warn_ignored_character(*yytext);
-	\n	{
-		BEGIN(INITIAL);
-		return T_EOL;
-	}
-}
+#.*			/* ignore comment */
+[ \t]*			/* whitespaces */
+\\\n			/* escaped new line */
+\n			return T_EOL;
+"allnoconfig_y"		return T_ALLNOCONFIG_Y;
+"bool"			return T_BOOL;
+"choice"		return T_CHOICE;
+"comment"		return T_COMMENT;
+"config"		return T_CONFIG;
+"default"		return T_DEFAULT;
+"def_bool"		return T_DEF_BOOL;
+"defconfig_list"	return T_DEFCONFIG_LIST;
+"def_tristate"		return T_DEF_TRISTATE;
+"depends"		return T_DEPENDS;
+"endchoice"		return T_ENDCHOICE;
+"endif"			return T_ENDIF;
+"endmenu"		return T_ENDMENU;
+"help"|"---help---"	return T_HELP;
+"hex"			return T_HEX;
+"if"			return T_IF;
+"imply"			return T_IMPLY;
+"int"			return T_INT;
+"mainmenu"		return T_MAINMENU;
+"menuconfig"		return T_MENUCONFIG;
+"menu"			return T_MENU;
+"modules"		return T_MODULES;
+"on"			return T_ON;
+"optional"		return T_OPTIONAL;
+"option"		return T_OPTION;
+"prompt"		return T_PROMPT;
+"range"			return T_RANGE;
+"select"		return T_SELECT;
+"source"		return T_SOURCE;
+"string"		return T_STRING;
+"tristate"		return T_TRISTATE;
+"visible"		return T_VISIBLE;
+"||"			return T_OR;
+"&&"			return T_AND;
+"="			return T_EQUAL;
+"!="			return T_UNEQUAL;
+"<"			return T_LESS;
+"<="			return T_LESS_EQUAL;
+">"			return T_GREATER;
+">="			return T_GREATER_EQUAL;
+"!"			return T_NOT;
+"("			return T_OPEN_PAREN;
+")"			return T_CLOSE_PAREN;
+":="			return T_COLON_EQUAL;
+"+="			return T_PLUS_EQUAL;
+\"|\'			{
+				str = yytext[0];
+				new_string();
+				BEGIN(STRING);
+			}
+{n}+			{
+				alloc_string(yytext, yyleng);
+				yylval.string = text;
+				return T_WORD;
+			}
+({n}|$)+		{
+				/* this token includes at least one '$' */
+				yylval.string = expand_token(yytext, yyleng);
+				if (strlen(yylval.string))
+					return T_WORD;
+				free(yylval.string);
+			}
+.			warn_ignored_character(*yytext);
 
 <ASSIGN_VAL>{
 	[^[:blank:]\n]+.*	{
@@ -144,49 +172,6 @@ n	[A-Za-z0-9_-]
 	.
 }
 
-<PARAM>{
-	"modules"		return T_MODULES;
-	"defconfig_list"	return T_DEFCONFIG_LIST;
-	"allnoconfig_y"		return T_ALLNOCONFIG_Y;
-	"&&"	return T_AND;
-	"||"	return T_OR;
-	"("	return T_OPEN_PAREN;
-	")"	return T_CLOSE_PAREN;
-	"!"	return T_NOT;
-	"="	return T_EQUAL;
-	"!="	return T_UNEQUAL;
-	"<="	return T_LESS_EQUAL;
-	">="	return T_GREATER_EQUAL;
-	"<"	return T_LESS;
-	">"	return T_GREATER;
-	\"|\'	{
-		str = yytext[0];
-		new_string();
-		BEGIN(STRING);
-	}
-	\n	BEGIN(INITIAL); return T_EOL;
-	{n}+	{
-		const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
-		if (id && id->flags & TF_PARAM) {
-			return id->token;
-		}
-		alloc_string(yytext, yyleng);
-		yylval.string = text;
-		return T_WORD;
-	}
-	({n}|$)+	{
-		/* this token includes at least one '$' */
-		yylval.string = expand_token(yytext, yyleng);
-		if (strlen(yylval.string))
-			return T_WORD;
-		free(yylval.string);
-	}
-	#.*	/* comment */
-	\\\n	;
-	[[:blank:]]+
-	.	warn_ignored_character(*yytext);
-}
-
 <STRING>{
 	"$".*	append_expanded_string(yytext);
 	[^$'"\\\n]+	{
@@ -197,7 +182,7 @@ n	[A-Za-z0-9_-]
 	}
 	\'|\"	{
 		if (str == yytext[0]) {
-			BEGIN(PARAM);
+			BEGIN(INITIAL);
 			yylval.string = text;
 			return T_WORD_QUOTE;
 		} else
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index c611d70..35c373d 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -110,11 +110,6 @@ static struct menu *current_menu, *current_entry;
 		menu_end_menu();
 } if_entry menu_entry choice_entry
 
-%{
-/* Include kconf_id.c here so it can see the token constants. */
-#include "kconf_id.c"
-%}
-
 %%
 input: mainmenu_stmt stmt_list | stmt_list;
 
-- 
2.7.4


  parent reply	other threads:[~2018-12-11 11:02 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11 11:00 [PATCH 00/27] kconfig: remove all reduce/shift conflicts, refactor lexer, fix various issues Masahiro Yamada
2018-12-11 11:00 ` Masahiro Yamada
2018-12-11 11:00 ` Masahiro Yamada
2018-12-11 11:00 ` [PATCH 01/27] kconfig: fix file name and line number of warn_ignored_character() Masahiro Yamada
2018-12-11 11:00 ` [PATCH 02/27] kconfig: fix memory leak when EOF is encountered in quotation Masahiro Yamada
2018-12-11 11:00 ` [PATCH 03/27] kconfig: require T_EOL to reduce visible statement Masahiro Yamada
2018-12-11 11:00 ` [PATCH 04/27] kconfig: remove unneeded pattern matching to whitespaces Masahiro Yamada
2018-12-11 11:00 ` [PATCH 05/27] kconfig: refactor pattern matching in STRING state Masahiro Yamada
2018-12-11 11:00 ` [PATCH 06/27] kconfig: fix ambiguous grammar in terms of new lines Masahiro Yamada
2018-12-11 11:00 ` [PATCH 07/27] kconfig: clean up EOF handling in the lexer Masahiro Yamada
2018-12-11 11:00 ` [PATCH 08/27] kconfig: warn no new line at end of file Masahiro Yamada
2018-12-11 11:00 ` [PATCH 09/27] kconfig: remove grammatically ambiguous "unexpected option" diagnostic Masahiro Yamada
2018-12-11 11:00 ` [PATCH 10/27] kconfig: remove grammatically ambiguous option_error Masahiro Yamada
2018-12-11 11:00 ` [PATCH 11/27] kconfig: remove redundant if_block rule Masahiro Yamada
2018-12-11 11:00 ` [PATCH 12/27] kconfig: remove redundant menu_block rule Masahiro Yamada
2018-12-11 11:00 ` [PATCH 13/27] kconfig: loosen the order of "visible" and "depends on" in menu entry Masahiro Yamada
2018-12-11 11:00 ` [PATCH 14/27] kconfig: rename depends_list to comment_option_list Masahiro Yamada
2018-12-11 11:00 ` [PATCH 15/27] kconfig: remove redundant token defines Masahiro Yamada
2018-12-11 11:00 ` [PATCH 16/27] kconfig: use distinct tokens for type and default properties Masahiro Yamada
2018-12-11 11:01 ` [PATCH 17/27] kconfig: refactor scanning and parsing "option" properties Masahiro Yamada
2018-12-11 11:01 ` [PATCH 18/27] kconfig: use specific tokens instead of T_ASSIGN for assignments Masahiro Yamada
2018-12-11 11:01 ` [PATCH 19/27] kconfig: use T_WORD instead of T_VARIABLE for variables Masahiro Yamada
2018-12-11 11:01 ` [PATCH 20/27] microblaze: surround string default in Kconfig with double quotes Masahiro Yamada
2018-12-12  8:28   ` Michal Simek
2018-12-11 11:01 ` [PATCH 21/27] treewide: surround file paths in Kconfig files " Masahiro Yamada
2018-12-11 11:01   ` Masahiro Yamada
2018-12-11 11:01   ` Masahiro Yamada
2018-12-11 11:19   ` Wolfram Sang
2018-12-11 11:19     ` Wolfram Sang
2018-12-11 11:25   ` Geert Uytterhoeven
2018-12-11 11:25     ` Geert Uytterhoeven
2018-12-11 14:43   ` Ingo Molnar
2018-12-11 14:43     ` Ingo Molnar
2018-12-11 11:01 ` [PATCH 22/27] kconfig: ban the use of '.' and '/' in unquoted words Masahiro Yamada
2018-12-11 11:01 ` [PATCH 23/27] kconfig: refactor end token rules Masahiro Yamada
2018-12-11 11:01 ` [PATCH 24/27] kconfig: stop associating kconf_id with yylval Masahiro Yamada
2018-12-11 11:01 ` [PATCH 25/27] kconfig: switch to ASSIGN_VAL state in the second lexer Masahiro Yamada
2018-12-11 11:01 ` [PATCH 26/27] kconfig: update current_pos " Masahiro Yamada
2018-12-11 11:01 ` Masahiro Yamada [this message]
2018-12-19 14:59 ` [PATCH 00/27] kconfig: remove all reduce/shift conflicts, refactor lexer, fix various issues Masahiro Yamada
2018-12-19 14:59   ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1544526070-16690-28-git-send-email-yamada.masahiro@socionext.com \
    --to=yamada.masahiro@socionext.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ulfalizer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.