From: Ethan Sommer <e5ten.arch@gmail.com>
Cc: Ethan Sommer <e5ten.arch@gmail.com>,
Masahiro Yamada <masahiroy@kernel.org>,
Michal Marek <michal.lkml@markovi.net>,
Nathan Chancellor <natechancellor@gmail.com>,
Nick Desaulniers <ndesaulniers@google.com>,
Sedat Dilek <sedat.dilek@gmail.com>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] make yacc usage POSIX-compliant
Date: Thu, 30 Jan 2020 11:23:11 -0500 [thread overview]
Message-ID: <20200130162314.31449-1-e5ten.arch@gmail.com> (raw)
use -b and -d to generate correctly named source and header files,
instead of bison-specific --defines and non-POSIX -o
check that YACC command is found in path or is an executable file,
instead of using bison-specific --version flag to display an error when
it is missing
explicitly define yyltype in scripts/genksyms/lex.l, instead of relying
on bison automatically defining it
replace bison-specific %destructor use in scripts/kconfig/parser.y
dtc's yacc usage is not covered here, as its use of bison-specific
features is much greater, and it is only built on certain architectures,
unlike kconfig and genksyms
Signed-off-by: Ethan Sommer <e5ten.arch@gmail.com>
---
scripts/Makefile.host | 2 +-
scripts/genksyms/Makefile | 6 ++++--
scripts/genksyms/lex.l | 2 ++
scripts/kconfig/parser.y | 14 +++++++-------
4 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 4c51c95d40f4..64e98e1d4825 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -11,7 +11,7 @@ $(obj)/%.lex.c: $(src)/%.l FORCE
# YACC
# ---------------------------------------------------------------------------
quiet_cmd_bison = YACC $(basename $@).[ch]
- cmd_bison = $(YACC) -o $(basename $@).c --defines=$(basename $@).h -t -l $<
+ cmd_bison = $(YACC) -b $(basename $(basename $@)) -d -t -l $<
$(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORCE
$(call if_changed,bison)
diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
index 78629f515e78..1e120328fa88 100644
--- a/scripts/genksyms/Makefile
+++ b/scripts/genksyms/Makefile
@@ -14,9 +14,11 @@ genksyms-objs := genksyms.o parse.tab.o lex.lex.o
# so that 'bison: not found' will be displayed if it is missing.
ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
+ifeq ($(shell command -v $(YACC) || [ -x $(YACC) ] && echo y),)
+ $(error command not found: $(YACC))
+endif
quiet_cmd_bison_no_warn = $(quiet_cmd_bison)
- cmd_bison_no_warn = $(YACC) --version >/dev/null; \
- $(cmd_bison) 2>/dev/null
+ cmd_bison_no_warn = $(cmd_bison) 2>/dev/null
$(obj)/pars%.tab.c $(obj)/pars%.tab.h: $(src)/pars%.y FORCE
$(call if_changed,bison_no_warn)
diff --git a/scripts/genksyms/lex.l b/scripts/genksyms/lex.l
index e265c5d96861..0580c088527f 100644
--- a/scripts/genksyms/lex.l
+++ b/scripts/genksyms/lex.l
@@ -19,6 +19,8 @@
#include "genksyms.h"
#include "parse.tab.h"
+extern YYSTYPE yylval;
+
/* We've got a two-level lexer here. We let flex do basic tokenization
and then we categorize those basic tokens in the second stage. */
#define YY_DECL static int yylex1(void)
diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y
index b3eff9613cf8..9eb9a94a68e0 100644
--- a/scripts/kconfig/parser.y
+++ b/scripts/kconfig/parser.y
@@ -20,6 +20,8 @@
int cdebug = PRINTD;
+int yynerrs = 0;
+
static void yyerror(const char *err);
static void zconfprint(const char *err, ...);
static void zconf_error(const char *err, ...);
@@ -101,13 +103,6 @@ static struct menu *current_menu, *current_entry;
%type <string> word_opt assign_val
%type <flavor> assign_op
-%destructor {
- fprintf(stderr, "%s:%d: missing end statement for this entry\n",
- $$->file->name, $$->lineno);
- if (current_menu == $$)
- menu_end_menu();
-} if_entry menu_entry choice_entry
-
%%
input: mainmenu_stmt stmt_list | stmt_list;
@@ -529,6 +524,11 @@ static bool zconf_endtoken(const char *tokenname,
if (strcmp(tokenname, expected_tokenname)) {
zconf_error("unexpected '%s' within %s block",
tokenname, expected_tokenname);
+ if (!strcmp(tokenname, "if") || !strcmp(tokenname, "menu") ||
+ !strcmp(tokenname, "choice"))
+ fprintf(stderr, "%s:%d: missing end statement for this entry\n",
+ current_menu->file->name, current_menu->lineno);
+ menu_end_menu();
yynerrs++;
return false;
}
--
2.25.0
WARNING: multiple messages have this Message-ID (diff)
From: Ethan Sommer <e5ten.arch@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Ethan Sommer <e5ten.arch@gmail.com>,
Masahiro Yamada <masahiroy@kernel.org>,
Michal Marek <michal.lkml@markovi.net>,
Nathan Chancellor <natechancellor@gmail.com>,
Nick Desaulniers <ndesaulniers@google.com>,
Sedat Dilek <sedat.dilek@gmail.com>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] make yacc usage POSIX-compliant
Date: Thu, 30 Jan 2020 11:23:11 -0500 [thread overview]
Message-ID: <20200130162314.31449-1-e5ten.arch@gmail.com> (raw)
use -b and -d to generate correctly named source and header files,
instead of bison-specific --defines and non-POSIX -o
check that YACC command is found in path or is an executable file,
instead of using bison-specific --version flag to display an error when
it is missing
explicitly define yyltype in scripts/genksyms/lex.l, instead of relying
on bison automatically defining it
replace bison-specific %destructor use in scripts/kconfig/parser.y
dtc's yacc usage is not covered here, as its use of bison-specific
features is much greater, and it is only built on certain architectures,
unlike kconfig and genksyms
Signed-off-by: Ethan Sommer <e5ten.arch@gmail.com>
---
scripts/Makefile.host | 2 +-
scripts/genksyms/Makefile | 6 ++++--
scripts/genksyms/lex.l | 2 ++
scripts/kconfig/parser.y | 14 +++++++-------
4 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 4c51c95d40f4..64e98e1d4825 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -11,7 +11,7 @@ $(obj)/%.lex.c: $(src)/%.l FORCE
# YACC
# ---------------------------------------------------------------------------
quiet_cmd_bison = YACC $(basename $@).[ch]
- cmd_bison = $(YACC) -o $(basename $@).c --defines=$(basename $@).h -t -l $<
+ cmd_bison = $(YACC) -b $(basename $(basename $@)) -d -t -l $<
$(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORCE
$(call if_changed,bison)
diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
index 78629f515e78..1e120328fa88 100644
--- a/scripts/genksyms/Makefile
+++ b/scripts/genksyms/Makefile
@@ -14,9 +14,11 @@ genksyms-objs := genksyms.o parse.tab.o lex.lex.o
# so that 'bison: not found' will be displayed if it is missing.
ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
+ifeq ($(shell command -v $(YACC) || [ -x $(YACC) ] && echo y),)
+ $(error command not found: $(YACC))
+endif
quiet_cmd_bison_no_warn = $(quiet_cmd_bison)
- cmd_bison_no_warn = $(YACC) --version >/dev/null; \
- $(cmd_bison) 2>/dev/null
+ cmd_bison_no_warn = $(cmd_bison) 2>/dev/null
$(obj)/pars%.tab.c $(obj)/pars%.tab.h: $(src)/pars%.y FORCE
$(call if_changed,bison_no_warn)
diff --git a/scripts/genksyms/lex.l b/scripts/genksyms/lex.l
index e265c5d96861..0580c088527f 100644
--- a/scripts/genksyms/lex.l
+++ b/scripts/genksyms/lex.l
@@ -19,6 +19,8 @@
#include "genksyms.h"
#include "parse.tab.h"
+extern YYSTYPE yylval;
+
/* We've got a two-level lexer here. We let flex do basic tokenization
and then we categorize those basic tokens in the second stage. */
#define YY_DECL static int yylex1(void)
diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y
index b3eff9613cf8..9eb9a94a68e0 100644
--- a/scripts/kconfig/parser.y
+++ b/scripts/kconfig/parser.y
@@ -20,6 +20,8 @@
int cdebug = PRINTD;
+int yynerrs = 0;
+
static void yyerror(const char *err);
static void zconfprint(const char *err, ...);
static void zconf_error(const char *err, ...);
@@ -101,13 +103,6 @@ static struct menu *current_menu, *current_entry;
%type <string> word_opt assign_val
%type <flavor> assign_op
-%destructor {
- fprintf(stderr, "%s:%d: missing end statement for this entry\n",
- $$->file->name, $$->lineno);
- if (current_menu == $$)
- menu_end_menu();
-} if_entry menu_entry choice_entry
-
%%
input: mainmenu_stmt stmt_list | stmt_list;
@@ -529,6 +524,11 @@ static bool zconf_endtoken(const char *tokenname,
if (strcmp(tokenname, expected_tokenname)) {
zconf_error("unexpected '%s' within %s block",
tokenname, expected_tokenname);
+ if (!strcmp(tokenname, "if") || !strcmp(tokenname, "menu") ||
+ !strcmp(tokenname, "choice"))
+ fprintf(stderr, "%s:%d: missing end statement for this entry\n",
+ current_menu->file->name, current_menu->lineno);
+ menu_end_menu();
yynerrs++;
return false;
}
--
2.25.0
next reply other threads:[~2020-01-30 16:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-30 16:23 Ethan Sommer [this message]
2020-01-30 16:23 ` [PATCH] make yacc usage POSIX-compliant Ethan Sommer
2020-02-16 5:08 ` 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=20200130162314.31449-1-e5ten.arch@gmail.com \
--to=e5ten.arch@gmail.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=michal.lkml@markovi.net \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
--cc=sedat.dilek@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.