linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] kconfig: use default 'yy' prefix for lexer and parser
@ 2018-01-12  0:58 Masahiro Yamada
  2018-01-12  0:58 ` [PATCH 2/2] kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIX Masahiro Yamada
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Masahiro Yamada @ 2018-01-12  0:58 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Michal Marek, Sam Ravnborg, Ulf Magnusson, Luis R . Rodriguez,
	Masahiro Yamada, linux-kernel

Flex and Bison provide an option to change the prefix of globally-
visible symbols.  This is useful to link multiple lexers and/or
parsers into the same executable.  However, Kconfig (and any other
host programs in kernel) uses a single lexer and parser.  I do not
see a good reason to change the default 'yy' prefix.

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

 scripts/kconfig/Makefile |  3 ---
 scripts/kconfig/zconf.l  | 16 ++++++++--------
 scripts/kconfig/zconf.y  | 22 +++++++++++-----------
 3 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 61cdc5e..2ad1cf5 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -211,9 +211,6 @@ HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC)
 HOSTCFLAGS_zconf.lex.o	:= -I$(src)
 HOSTCFLAGS_zconf.tab.o	:= -I$(src)
 
-LEX_PREFIX_zconf	:= zconf
-YACC_PREFIX_zconf	:= zconf
-
 HOSTLOADLIBES_qconf	= $(KC_QT_LIBS)
 HOSTCXXFLAGS_qconf.o	= $(KC_QT_CFLAGS)
 
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index c410d25..07e074d 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -106,11 +106,11 @@ n	[A-Za-z0-9_-]
 		current_pos.file = current_file;
 		current_pos.lineno = current_file->lineno;
 		if (id && id->flags & TF_COMMAND) {
-			zconflval.id = id;
+			yylval.id = id;
 			return id->token;
 		}
 		alloc_string(yytext, yyleng);
-		zconflval.string = text;
+		yylval.string = text;
 		return T_WORD;
 	}
 	.	warn_ignored_character(*yytext);
@@ -142,11 +142,11 @@ n	[A-Za-z0-9_-]
 	({n}|[/.])+	{
 		const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
 		if (id && id->flags & TF_PARAM) {
-			zconflval.id = id;
+			yylval.id = id;
 			return id->token;
 		}
 		alloc_string(yytext, yyleng);
-		zconflval.string = text;
+		yylval.string = text;
 		return T_WORD;
 	}
 	#.*	/* comment */
@@ -161,7 +161,7 @@ n	[A-Za-z0-9_-]
 <STRING>{
 	[^'"\\\n]+/\n	{
 		append_string(yytext, yyleng);
-		zconflval.string = text;
+		yylval.string = text;
 		return T_WORD_QUOTE;
 	}
 	[^'"\\\n]+	{
@@ -169,7 +169,7 @@ n	[A-Za-z0-9_-]
 	}
 	\\.?/\n	{
 		append_string(yytext + 1, yyleng - 1);
-		zconflval.string = text;
+		yylval.string = text;
 		return T_WORD_QUOTE;
 	}
 	\\.?	{
@@ -178,7 +178,7 @@ n	[A-Za-z0-9_-]
 	\'|\"	{
 		if (str == yytext[0]) {
 			BEGIN(PARAM);
-			zconflval.string = text;
+			yylval.string = text;
 			return T_WORD_QUOTE;
 		} else
 			append_string(yytext, 1);
@@ -261,7 +261,7 @@ void zconf_starthelp(void)
 
 static void zconf_endhelp(void)
 {
-	zconflval.string = text;
+	yylval.string = text;
 	BEGIN(INITIAL);
 }
 
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 600deb1..dd0c09d 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -20,10 +20,10 @@
 
 int cdebug = PRINTD;
 
-extern int zconflex(void);
+int yylex(void);
+static void yyerror(const char *err);
 static void zconfprint(const char *err, ...);
 static void zconf_error(const char *err, ...);
-static void zconferror(const char *err);
 static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken);
 
 struct symbol *symbol_hash[SYMBOL_HASHSIZE];
@@ -529,9 +529,9 @@ void conf_parse(const char *name)
 	_menu_init();
 
 	if (getenv("ZCONF_DEBUG"))
-		zconfdebug = 1;
-	zconfparse();
-	if (zconfnerrs)
+		yydebug = 1;
+	yyparse();
+	if (yynerrs)
 		exit(1);
 	if (!modules_sym)
 		modules_sym = sym_find( "n" );
@@ -544,9 +544,9 @@ void conf_parse(const char *name)
 	menu_finalize(&rootmenu);
 	for_all_symbols(i, sym) {
 		if (sym_check_deps(sym))
-			zconfnerrs++;
+			yynerrs++;
 	}
-	if (zconfnerrs)
+	if (yynerrs)
 		exit(1);
 	sym_set_change_count(1);
 }
@@ -571,7 +571,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok
 	if (id->token != endtoken) {
 		zconf_error("unexpected '%s' within %s block",
 			id->name, zconf_tokenname(starttoken));
-		zconfnerrs++;
+		yynerrs++;
 		return false;
 	}
 	if (current_menu->file != current_file) {
@@ -580,7 +580,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok
 		fprintf(stderr, "%s:%d: location of the '%s'\n",
 			current_menu->file->name, current_menu->lineno,
 			zconf_tokenname(starttoken));
-		zconfnerrs++;
+		yynerrs++;
 		return false;
 	}
 	return true;
@@ -601,7 +601,7 @@ static void zconf_error(const char *err, ...)
 {
 	va_list ap;
 
-	zconfnerrs++;
+	yynerrs++;
 	fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
 	va_start(ap, err);
 	vfprintf(stderr, err, ap);
@@ -609,7 +609,7 @@ static void zconf_error(const char *err, ...)
 	fprintf(stderr, "\n");
 }
 
-static void zconferror(const char *err)
+static void yyerror(const char *err)
 {
 	fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIX
  2018-01-12  0:58 [PATCH 1/2] kconfig: use default 'yy' prefix for lexer and parser Masahiro Yamada
@ 2018-01-12  0:58 ` Masahiro Yamada
  2018-01-12 11:05   ` Ulf Magnusson
  2018-01-12 11:04 ` [PATCH 1/2] kconfig: use default 'yy' prefix for lexer and parser Ulf Magnusson
  2018-01-18 14:05 ` Masahiro Yamada
  2 siblings, 1 reply; 5+ messages in thread
From: Masahiro Yamada @ 2018-01-12  0:58 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Michal Marek, Sam Ravnborg, Ulf Magnusson, Luis R . Rodriguez,
	Masahiro Yamada, linux-kernel

Kconfig was the only user of these.  With Kconfig converted to use
the default 'yy' prefix, we do not need them any more.

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

 scripts/Makefile.lib | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 0f9ef3f..5ff2761 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -188,10 +188,8 @@ endef
 
 # LEX
 # ---------------------------------------------------------------------------
-LEX_PREFIX = $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy)
-
 quiet_cmd_flex = LEX     $@
-      cmd_flex = $(LEX) -o$@ -L -P $(LEX_PREFIX) $<
+      cmd_flex = $(LEX) -o$@ -L $<
 
 ifdef REGENERATE_PARSERS
 .PRECIOUS: $(src)/%.lex.c_shipped
@@ -205,10 +203,8 @@ $(filter %.lex.c,$(targets)): $(obj)/%.lex.c: $(src)/%.l FORCE
 
 # YACC
 # ---------------------------------------------------------------------------
-YACC_PREFIX = $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy)
-
 quiet_cmd_bison = YACC    $@
-      cmd_bison = $(YACC) -o$@ -t -l -p $(YACC_PREFIX) $<
+      cmd_bison = $(YACC) -o$@ -t -l $<
 
 ifdef REGENERATE_PARSERS
 .PRECIOUS: $(src)/%.tab.c_shipped
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] kconfig: use default 'yy' prefix for lexer and parser
  2018-01-12  0:58 [PATCH 1/2] kconfig: use default 'yy' prefix for lexer and parser Masahiro Yamada
  2018-01-12  0:58 ` [PATCH 2/2] kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIX Masahiro Yamada
@ 2018-01-12 11:04 ` Ulf Magnusson
  2018-01-18 14:05 ` Masahiro Yamada
  2 siblings, 0 replies; 5+ messages in thread
From: Ulf Magnusson @ 2018-01-12 11:04 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Linux Kbuild mailing list, Michal Marek, Sam Ravnborg,
	Luis R . Rodriguez, Linux Kernel Mailing List

On Fri, Jan 12, 2018 at 1:58 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> Flex and Bison provide an option to change the prefix of globally-
> visible symbols.  This is useful to link multiple lexers and/or
> parsers into the same executable.  However, Kconfig (and any other
> host programs in kernel) uses a single lexer and parser.  I do not
> see a good reason to change the default 'yy' prefix.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  scripts/kconfig/Makefile |  3 ---
>  scripts/kconfig/zconf.l  | 16 ++++++++--------
>  scripts/kconfig/zconf.y  | 22 +++++++++++-----------
>  3 files changed, 19 insertions(+), 22 deletions(-)
>
> diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
> index 61cdc5e..2ad1cf5 100644
> --- a/scripts/kconfig/Makefile
> +++ b/scripts/kconfig/Makefile
> @@ -211,9 +211,6 @@ HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC)
>  HOSTCFLAGS_zconf.lex.o := -I$(src)
>  HOSTCFLAGS_zconf.tab.o := -I$(src)
>
> -LEX_PREFIX_zconf       := zconf
> -YACC_PREFIX_zconf      := zconf
> -
>  HOSTLOADLIBES_qconf    = $(KC_QT_LIBS)
>  HOSTCXXFLAGS_qconf.o   = $(KC_QT_CFLAGS)
>
> diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
> index c410d25..07e074d 100644
> --- a/scripts/kconfig/zconf.l
> +++ b/scripts/kconfig/zconf.l
> @@ -106,11 +106,11 @@ n [A-Za-z0-9_-]
>                 current_pos.file = current_file;
>                 current_pos.lineno = current_file->lineno;
>                 if (id && id->flags & TF_COMMAND) {
> -                       zconflval.id = id;
> +                       yylval.id = id;
>                         return id->token;
>                 }
>                 alloc_string(yytext, yyleng);
> -               zconflval.string = text;
> +               yylval.string = text;
>                 return T_WORD;
>         }
>         .       warn_ignored_character(*yytext);
> @@ -142,11 +142,11 @@ n [A-Za-z0-9_-]
>         ({n}|[/.])+     {
>                 const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
>                 if (id && id->flags & TF_PARAM) {
> -                       zconflval.id = id;
> +                       yylval.id = id;
>                         return id->token;
>                 }
>                 alloc_string(yytext, yyleng);
> -               zconflval.string = text;
> +               yylval.string = text;
>                 return T_WORD;
>         }
>         #.*     /* comment */
> @@ -161,7 +161,7 @@ n   [A-Za-z0-9_-]
>  <STRING>{
>         [^'"\\\n]+/\n   {
>                 append_string(yytext, yyleng);
> -               zconflval.string = text;
> +               yylval.string = text;
>                 return T_WORD_QUOTE;
>         }
>         [^'"\\\n]+      {
> @@ -169,7 +169,7 @@ n   [A-Za-z0-9_-]
>         }
>         \\.?/\n {
>                 append_string(yytext + 1, yyleng - 1);
> -               zconflval.string = text;
> +               yylval.string = text;
>                 return T_WORD_QUOTE;
>         }
>         \\.?    {
> @@ -178,7 +178,7 @@ n   [A-Za-z0-9_-]
>         \'|\"   {
>                 if (str == yytext[0]) {
>                         BEGIN(PARAM);
> -                       zconflval.string = text;
> +                       yylval.string = text;
>                         return T_WORD_QUOTE;
>                 } else
>                         append_string(yytext, 1);
> @@ -261,7 +261,7 @@ void zconf_starthelp(void)
>
>  static void zconf_endhelp(void)
>  {
> -       zconflval.string = text;
> +       yylval.string = text;
>         BEGIN(INITIAL);
>  }
>
> diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
> index 600deb1..dd0c09d 100644
> --- a/scripts/kconfig/zconf.y
> +++ b/scripts/kconfig/zconf.y
> @@ -20,10 +20,10 @@
>
>  int cdebug = PRINTD;
>
> -extern int zconflex(void);
> +int yylex(void);
> +static void yyerror(const char *err);
>  static void zconfprint(const char *err, ...);
>  static void zconf_error(const char *err, ...);
> -static void zconferror(const char *err);
>  static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken);
>
>  struct symbol *symbol_hash[SYMBOL_HASHSIZE];
> @@ -529,9 +529,9 @@ void conf_parse(const char *name)
>         _menu_init();
>
>         if (getenv("ZCONF_DEBUG"))
> -               zconfdebug = 1;
> -       zconfparse();
> -       if (zconfnerrs)
> +               yydebug = 1;
> +       yyparse();
> +       if (yynerrs)
>                 exit(1);
>         if (!modules_sym)
>                 modules_sym = sym_find( "n" );
> @@ -544,9 +544,9 @@ void conf_parse(const char *name)
>         menu_finalize(&rootmenu);
>         for_all_symbols(i, sym) {
>                 if (sym_check_deps(sym))
> -                       zconfnerrs++;
> +                       yynerrs++;
>         }
> -       if (zconfnerrs)
> +       if (yynerrs)
>                 exit(1);
>         sym_set_change_count(1);
>  }
> @@ -571,7 +571,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok
>         if (id->token != endtoken) {
>                 zconf_error("unexpected '%s' within %s block",
>                         id->name, zconf_tokenname(starttoken));
> -               zconfnerrs++;
> +               yynerrs++;
>                 return false;
>         }
>         if (current_menu->file != current_file) {
> @@ -580,7 +580,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok
>                 fprintf(stderr, "%s:%d: location of the '%s'\n",
>                         current_menu->file->name, current_menu->lineno,
>                         zconf_tokenname(starttoken));
> -               zconfnerrs++;
> +               yynerrs++;
>                 return false;
>         }
>         return true;
> @@ -601,7 +601,7 @@ static void zconf_error(const char *err, ...)
>  {
>         va_list ap;
>
> -       zconfnerrs++;
> +       yynerrs++;
>         fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
>         va_start(ap, err);
>         vfprintf(stderr, err, ap);
> @@ -609,7 +609,7 @@ static void zconf_error(const char *err, ...)
>         fprintf(stderr, "\n");
>  }
>
> -static void zconferror(const char *err)
> +static void yyerror(const char *err)
>  {
>         fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
>  }
> --
> 2.7.4
>

Looks good to me. Less cryptic.

Acked-by: Ulf Magnusson <ulfalizer@gmail.com>

Cheers,
Ulf

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIX
  2018-01-12  0:58 ` [PATCH 2/2] kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIX Masahiro Yamada
@ 2018-01-12 11:05   ` Ulf Magnusson
  0 siblings, 0 replies; 5+ messages in thread
From: Ulf Magnusson @ 2018-01-12 11:05 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Linux Kbuild mailing list, Michal Marek, Sam Ravnborg,
	Luis R . Rodriguez, Linux Kernel Mailing List

On Fri, Jan 12, 2018 at 1:58 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> Kconfig was the only user of these.  With Kconfig converted to use
> the default 'yy' prefix, we do not need them any more.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  scripts/Makefile.lib | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 0f9ef3f..5ff2761 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -188,10 +188,8 @@ endef
>
>  # LEX
>  # ---------------------------------------------------------------------------
> -LEX_PREFIX = $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy)
> -
>  quiet_cmd_flex = LEX     $@
> -      cmd_flex = $(LEX) -o$@ -L -P $(LEX_PREFIX) $<
> +      cmd_flex = $(LEX) -o$@ -L $<
>
>  ifdef REGENERATE_PARSERS
>  .PRECIOUS: $(src)/%.lex.c_shipped
> @@ -205,10 +203,8 @@ $(filter %.lex.c,$(targets)): $(obj)/%.lex.c: $(src)/%.l FORCE
>
>  # YACC
>  # ---------------------------------------------------------------------------
> -YACC_PREFIX = $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy)
> -
>  quiet_cmd_bison = YACC    $@
> -      cmd_bison = $(YACC) -o$@ -t -l -p $(YACC_PREFIX) $<
> +      cmd_bison = $(YACC) -o$@ -t -l $<
>
>  ifdef REGENERATE_PARSERS
>  .PRECIOUS: $(src)/%.tab.c_shipped
> --
> 2.7.4
>

Acked-by: Ulf Magnusson <ulfalizer@gmail.com>

Cheers,
Ulf

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] kconfig: use default 'yy' prefix for lexer and parser
  2018-01-12  0:58 [PATCH 1/2] kconfig: use default 'yy' prefix for lexer and parser Masahiro Yamada
  2018-01-12  0:58 ` [PATCH 2/2] kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIX Masahiro Yamada
  2018-01-12 11:04 ` [PATCH 1/2] kconfig: use default 'yy' prefix for lexer and parser Ulf Magnusson
@ 2018-01-18 14:05 ` Masahiro Yamada
  2 siblings, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2018-01-18 14:05 UTC (permalink / raw)
  To: Linux Kbuild mailing list
  Cc: Michal Marek, Sam Ravnborg, Ulf Magnusson, Luis R . Rodriguez,
	Masahiro Yamada, Linux Kernel Mailing List

2018-01-12 9:58 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> Flex and Bison provide an option to change the prefix of globally-
> visible symbols.  This is useful to link multiple lexers and/or
> parsers into the same executable.  However, Kconfig (and any other
> host programs in kernel) uses a single lexer and parser.  I do not
> see a good reason to change the default 'yy' prefix.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>

Applied both patches to linux-kbuild/kconfig.



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-18 14:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-12  0:58 [PATCH 1/2] kconfig: use default 'yy' prefix for lexer and parser Masahiro Yamada
2018-01-12  0:58 ` [PATCH 2/2] kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIX Masahiro Yamada
2018-01-12 11:05   ` Ulf Magnusson
2018-01-12 11:04 ` [PATCH 1/2] kconfig: use default 'yy' prefix for lexer and parser Ulf Magnusson
2018-01-18 14:05 ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).