$(NULL)
AM_YFLAGS = -d -Wno-yacc
+if BISON_CUSTOM_ERROR
+YACC += -D parse.error=custom -D parse.lac=full
+else
+YACC += -D parse.error=verbose
+endif
if BUILD_PROFILING
AM_CFLAGS += --coverage
AC_PROG_LEX([noyywrap])
AC_PROG_YACC
-if test -z "$ac_cv_prog_YACC" -a ! -f "${srcdir}/src/parser_bison.c"
+p_bison_pfx="${srcdir}/src/parser_bison"
+if test -f "${p_bison_pfx}.c" -a "${p_bison_pfx}.c" -nt "${p_bison_pfx}.y"
+then
+ have_prebuilt_bison="yes"
+elif test -z "$ac_cv_prog_YACC"
then
echo "*** Error: No suitable bison/yacc found. ***"
echo " Please install the 'bison' package."
exit 1
fi
+AC_ARG_ENABLE([extended_parser_errors],
+ AS_HELP_STRING([--disable-extended-parser-errors],
+ [Disable use of parse.error=custom and LAC in Bison]),
+ [], [
+ enable_extended_parser_errors=no
+ AC_SUBST([BISON], [$ac_cv_prog_YACC])
+ AX_PROG_BISON_VERSION([3.6],
+ [enable_extended_parser_errors=yes])
+ ])
+AM_CONDITIONAL([BISON_CUSTOM_ERROR],
+ [test "x$enable_extended_parser_errors" != xno])
+
AM_PROG_AR
LT_INIT([disable-static])
AC_EXEEXT
json output support: ${with_json}
collect profiling data: ${enable_profiling}"
+if test "x$have_prebuilt_bison" != "xyes"; then
+echo " extended parser errors: ${enable_extended_parser_errors}"
+fi
+
if test "x$unitdir" != "x"; then
AC_SUBST([unitdir])
echo " systemd unit: ${unitdir}"
int nft_run_cmd_from_buffer(struct nft_ctx *nft, const char *buf);
int nft_run_cmd_from_filename(struct nft_ctx *nft, const char *filename);
+extern bool nft_bison_have_extended_errors;
+
#ifdef __cplusplus
} /* extern "C" */
#endif
nft_ctx_input_get_flags;
nft_ctx_input_set_flags;
} LIBNFTABLES_3;
+
+LIBNFTABLES_5 {
+ nft_bison_have_extended_errors;
+} LIBNFTABLES_4;
static void show_version(void)
{
- const char *cli, *minigmp, *json, *xt;
+ const char *cli, *minigmp, *json, *xt, *ext_bsn_err;
#if defined(HAVE_LIBREADLINE)
cli = "readline";
#else
xt = "no";
#endif
+ ext_bsn_err = nft_bison_have_extended_errors ? "yes" : "no";
printf("%s v%s (%s)\n"
- " cli: %s\n"
- " json: %s\n"
- " minigmp: %s\n"
- " libxtables: %s\n",
+ " cli: %s\n"
+ " json: %s\n"
+ " minigmp: %s\n"
+ " libxtables: %s\n"
+ " extended parser errors: %s\n",
PACKAGE_NAME, PACKAGE_VERSION, RELEASE_NAME,
- cli, json, minigmp, xt);
+ cli, json, minigmp, xt, ext_bsn_err);
}
%parse-param { void *scanner }
%parse-param { struct parser_state *state }
%lex-param { scanner }
-%define parse.error custom
-%define parse.lac full
%locations
%initial-action {
%%
+#ifdef YY_LAC_ESTABLISH
static int
yyreport_syntax_error(const yypcontext_t *yyctx, struct nft_ctx *nft,
void *scanner, struct parser_state *state)
free(msg);
return 0;
}
+
+bool nft_bison_have_extended_errors = true;
+#else /* ! YY_LAC_ESTABLISH */
+bool nft_bison_have_extended_errors = false;
+#endif /* YY_LAC_ESTABLISH */
+EXPORT_SYMBOL(nft_bison_have_extended_errors);