From: "Jan Kończak" <jan.konczak@cs.put.poznan.pl>
To: Phil Sutter <phil@nwl.cc>
Cc: Florian Westphal <fw@strlen.de>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft v2] parser_bison: on syntax errors, output expected tokens
Date: Thu, 04 Jun 2026 14:34:55 +0200 [thread overview]
Message-ID: <3901884.MHq7AAxBmi@imladris> (raw)
In-Reply-To: <aiCNWPqfVbTNIKI6@orbyte.nwl.cc>
> conditional setting of AM_YFLAGS variable in Makefile.am is problematic
> (...)
> what I tried was:
> | AM_YFLAGS = -d -Wno-yacc
> |
> | +if BISON_CUSTOM_ERROR
> | +AM_YFLAGS += …
Any conditional change in Makefile.am I came up with is put aside by
autotools. The lines "AM_YFLAGS += ..." end up in a ".PRECIOUS" target
in the resulting Makefile and are never applied before bison is called.
I guess moving the %define's from parser_bison.y to bison command line
arguments, and a '#if YYBISON >= 30704' that disables the error
reporting code is a way to go, one only must subdue the autotools.
The YYBISON macro generated by bison has the version encoded starting
from 3.7.4, hence that particular version.
My (working) take on that would be as follows, though I can tell that
mangling the options in configure.ac is a shitty workaround. I never
really wrote autotools configs myself, and I don't have a clue how to
do it better. Feel free to include any part of it in case it helps.
Regards, Jan
====================================================================
diff --git a/configure.ac b/configure.ac
index 0d3ee2ac..9b61cd38 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,6 +45,13 @@ then
exit 1
fi
+AC_PATH_PROG([BISON],[bison])
+AX_PROG_BISON_VERSION([3.7.4],[
+ AC_SUBST([YACC], [$(echo "$ac_cv_prog_YACC -D parse.error=custom -D parse.lac=full")])
+],[
+ AC_SUBST([YACC], [$(echo "$ac_cv_prog_YACC -D parse.error=verbose")])
+])
+
AM_PROG_AR
LT_INIT([disable-static])
AC_EXEEXT
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 5a334bf0..25b875ec 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -221,8 +221,14 @@ int nft_lex(void *, void *, void *);
%parse-param { void *scanner }
%parse-param { struct parser_state *state }
%lex-param { scanner }
-%define parse.error custom
-%define parse.lac full
+// Note: configure.ac controls the following defines:
+// if bison version is 3.7.4 or newer:
+// %define parse.lac full
+// %define parse.error custom
+// else
+// %define parse.error verbose
+// Notice that bison 3.6 introduces parse.error custom, but starting from
+// 3.7.4 a numeric macro enablkes checking version
%locations
%initial-action {
@@ -6537,6 +6543,7 @@ exthdr_key : HBH close_scope_hbh { $$ = IPPROTO_HOPOPTS; }
%%
+#if YYBISON >= 30704
static int
yyreport_syntax_error(const yypcontext_t *yyctx, struct nft_ctx *nft,
void *scanner, struct parser_state *state)
@@ -6592,3 +6599,4 @@ yyreport_syntax_error(const yypcontext_t *yyctx, struct nft_ctx *nft,
free(msg);
return 0;
}
+#endif
next prev parent reply other threads:[~2026-06-04 12:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-20 12:29 [PATCH nft v2] parser_bison: on syntax errors, output expected tokens Florian Westphal
2026-01-20 17:33 ` Jan Kończak
2026-01-20 22:39 ` Florian Westphal
2026-06-03 20:23 ` Phil Sutter
2026-06-04 12:34 ` Jan Kończak [this message]
2026-06-05 15:31 ` Phil Sutter
2026-06-06 11:37 ` Jan Kończak
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=3901884.MHq7AAxBmi@imladris \
--to=jan.konczak@cs.put.poznan.pl \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=phil@nwl.cc \
/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.