Missing semicolons at the end of actions are no longer added (as announced
in the release 2.5).
+*** Use of YACC='bison -y'
+
+ TL;DR: With Autoconf <= 2.69, pass -Wno-yacc to (AM_)YFLAGS if you use
+ Bison extensions.
+
+ Traditional Yacc generates 'y.tab.c' whatever the name of the input file.
+ Therefore Makefiles written for Yacc expect 'y.tab.c' (and possibly
+ 'y.tab.h' and 'y.outout') to be generated from 'foo.y'.
+
+ To this end, for ages, AC_PROG_YACC, Autoconf's macro to look for an
+ implementation of Yacc, was using Bison as 'bison -y'. While it does
+ ensure compatible output file names, it also enables warnings for
+ incompatibilities with POSIX Yacc. In other words, 'bison -y' triggers
+ warnings for Bison extensions.
+
+ Autoconf 2.70+ fixes this incompatibility by using YACC='bison -o y.tab.c'
+ (which also generates 'y.tab.h' and 'y.output' when needed).
+ Alternatively, disable Yacc warnings by passing '-Wno-yacc' to your Yacc
+ flags (YFLAGS, or AM_YFLAGS with Automake).
+
** Bug fixes
*** The epilogue is no longer affected by internal #defines (glr.c)
The %define variable api.value.type supports several special values. The
value "union" means that the user provides genuine types, not union member
- names such as "ival" and "sval" above.
+ names such as "ival" and "sval" above (WARNING: will fail if
+ -y/--yacc/%yacc is enabled).
%define api.value.type "union"
%token <int> INT "integer"
m4_define_default([b4_location_initial_column], [1])
m4_define_default([b4_location_initial_line], [1])
-# Sanity checks.
+
+## --------------- ##
+## Sanity checks. ##
+## --------------- ##
+
+# api.prefix >< %name-prefix.
b4_percent_define_ifdef([api.prefix],
[m4_ifdef([b4_prefix],
[b4_complain_at(b4_percent_define_get_loc([api.prefix]),
[%name-prefix],
[%define api.prefix])])])
+# api.value.type >< %union.
b4_percent_define_ifdef([api.value.type],
[m4_ifdef([b4_union_members],
[b4_complain_at(b4_percent_define_get_loc([api.value.type]),
[['%s' and '%s' cannot be used together]],
[%union],
[%define api.value.type])])])
+
+# api.value.type=union >< %yacc.
+b4_percent_define_ifdef([api.value.type],
+[m4_if(b4_percent_define_get([api.value.type]), [union],
+[b4_yacc_if(dnl
+[b4_complain_at(b4_percent_define_get_loc([api.value.type]),
+ [['%s' and '%s' cannot be used together]],
+ [%yacc],
+ [%define api.value.type "union"])])])])
return TOK_INT;
@end example
+This Bison extension cannot work if @code{%yacc} (or
+@option{-y}/@option{--yacc}) is enabled, as POSIX mandates that Yacc
+generate tokens as macros (e.g., @samp{#define INT 258}, or @samp{#define
+TOK_INT 258}).
+
This feature is new, and user feedback would be most welcome.
A similar feature is provided for C++ that in addition overcomes C++
[foo.c foo.h foo.output])
AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c],
[foo.output foo.tab.c foo.tab.h])
-AT_CHECK_OUTPUT([foo.y], [], [-dv -y],
- [y.output y.tab.c y.tab.h])
+
+AT_CHECK_OUTPUT([foo.y], [], [-dv -g --xml -y],
+ [y.dot y.output y.tab.c y.tab.h y.xml])
+# With '-o y.tab.c', we expect 'y.output' etc. (for compatility with Yacc).
+AT_CHECK_OUTPUT([foo.y], [], [-dv -g --xml -o y.tab.c],
+ [y.dot y.output y.tab.c y.tab.h y.xml])
+
AT_CHECK_OUTPUT([foo.y], [], [-dv -b bar],
[bar.output bar.tab.c bar.tab.h])
AT_CHECK_OUTPUT([foo.y], [], [-dv -g -o foo.c],
AT_CLEANUP
+## ---------------------------------------- ##
+## %yacc vs. %define api.value.type union. ##
+## ---------------------------------------- ##
+
+AT_SETUP([[%yacc vs. %define api.value.type union]])
+
+AT_DATA([[input.y]],
+[[%yacc
+%define api.value.type "union"
+%%
+exp: %empty;
+]])
+
+AT_BISON_CHECK([[input.y]], [[1]], [[]],
+[[input.y:2.9-22: error: '%yacc' and '%define api.value.type "union"' cannot be used together
+]])
+
+AT_CLEANUP
+
+
## ---------------- ##
## api.value.type. ##
## ---------------- ##