Compare commits

...
12 Commits
Author SHA1 Message Date
Akim Demaille 437f6250c5 version 3.3.2
* NEWS: Record release date.
2019-02-03 14:42:30 +01:00
Akim Demaille 334cb8f222 style: minor fixes
* NEWS, src/reduce.c, src/reduce.h: Use 'nonterminal'.
Fix comments.
2019-02-03 14:42:22 +01:00
Akim Demaille 03878edf77 NEWS: named constructors are preferable to symbol_type ctors
Reported by Frank Heckenbach.
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00043.html
2019-02-03 10:06:25 +01:00
Akim Demaille cacdfc2f6e gram: fix handling of nterms in actions when some are unused
Since Bison 3.3, semantic values in rule actions (i.e., '$...') are
passed to the m4 backend as the symbol number.  Unfortunately, when
there are unused symbols, the symbols are renumbered _after_ the
numbers were used in the rule actions.  As a result, the evaluation of
the skeleton failed because it used non existing symbol numbers.
Which is the happy scenario: we could use numbers of other existing
symbols...

Reported by Balázs Scheidler.
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00044.html

Translating the rule actions after the symbol renumbering moves too
many parts in bison.  Relying on the symbol identifiers is more
troublesome than it might first seem: some don't have an
identifier (tokens with only a literal string), some might have a
complex one (tokens with a literal string with characters special for
M4).  Well, these are tokens, but nterms also have issues: "dummy"
nterms (for midrule actions) are named $@32 etc. which is risky for
M4.

Instead, let's simply give M4 the mapping between the old numbers and
the new ones.  To avoid confusion between old and new numbers, always
emit pre-renumbering numbers as "orig NUM".

* data/README: Give details about "orig NUM".
* data/skeletons/bison.m4 (__b4_symbol, _b4_symbol): Resolve the
"orig NUM".
* src/output.c (prepare_symbol_definitions): Pass nterm_map to m4.
* src/reduce.h, src/reduce.c (nterm_map): Extract it from
nonterminals_reduce, to make it public.
(reduce_free): Free it.
* src/scan-code.l (handle_action_dollar): When referring to a nterm,
use "orig NUM".
* tests/reduce.at (Useless Parts): New, based Balázs Scheidler's
report.
2019-02-03 10:05:53 +01:00
Akim Demaille 31788ed4c7 style: rename local variable
* src/reduce.c (nonterminals_reduce): Rename nontermmap as nterm_map.
We will expose it.
2019-02-02 16:37:25 +01:00
Akim Demaille 69061fed82 CI: update the ICC serial number for travis-ci.org
On travis-ci.org, there are five concurrent slaves, instead of three
on travis-ci.com.
2019-01-28 08:12:13 +01:00
Akim Demaille 7a21067bb9 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-01-27 16:17:28 +01:00
Akim Demaille ed02d34fbc version 3.3.1
* NEWS: Record release date.
2019-01-27 16:03:23 +01:00
Akim Demaille 8b0b295569 yacc: issue warnings, not errors, for Bison extensions
Reported by Kiyoshi Kanazawa.
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00029.html

* src/getargs.c (getargs): Let --yacc imply -Wyacc, not -Werror=yacc.
* tests/input.at: Adjust.
* doc/bison.tex (Bison Options): Document.
2019-01-27 15:53:28 +01:00
Akim Demaille 59a108c0a6 style: formatting changes in NEWS and complain.c 2019-01-27 15:51:44 +01:00
Kiyoshi KanazawaandAkim Demaille 83ebc8bdb6 tests: don't depend on the user's definition of SHELL
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00031.html

* examples/test (SHELL): Set it to /bin/sh.
2019-01-27 07:06:44 +01:00
Akim Demaille 8023b3153a maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-01-26 11:45:20 +01:00
16 changed files with 242 additions and 83 deletions
+1 -1
View File
@@ -1 +1 @@
3.2.91
3.3.1
+2 -1
View File
@@ -8,7 +8,8 @@ language: cpp
env:
global:
# ICC serial number.
secure: ED3w6rzxuE6tVu3oyxha2MoGMRzRQCtinvr9uor1gw9TGKB80esTLx4KyX0xHemUdyQVarFDDQfVS5rf7jSDY8XiWIR6O+2Af9/30gb+8eyngyvACu7E28n+1XHmYWIEHsbvB9mic6C60FBj5sPcDnFWZeyttGL0WooSjYHiw1Egafwqbeu1mD3Aet9OI9VaLQvy0KcWAdVrYWSI9UWLvLM+xPVUjPFko4oS+dTlETzVnmn6JFbZX1OKONtfcvdoDRFBzs3iHm5dQUt/Fz+y/DtKSuvF3zvePHSgF6c8URbEPPjBdh87gkovSLyy+83fVeh4WMkF8b+dGZmikQv6kRsjKJdbQrS8tiMhZlORC5Gfmn4HXNgmapL+paUweakH7UZQHm6d5SZoBgCHNazfqMrywbZsZkGvZTDQIVG1Be7Lhh2BDFbPhPZNDvI9XYiqZP0QSb0BVfeO+AUSRcUPM7TvarxB74jYdfpTBu7sqJP6dSwhcDTEUhHmuLGjzsNm3uTZe8SUw/TGGx5uPTXNsCjJq6ClIOAIYXZTXLbBmIL/NBWCy0MUpD+9zsiknU7vzzq1RfgCCExhvYgosTjBLcX1kKI+eRSU5M44e+xCg4xx0m9WfafbKbhA20FfnWxCFIkZeVpkOOsexJ9zfe0SflVLxkd7vmci5SCBixLVbN0=
# See https://github.com/nemequ/icc-travis.
secure: B3manbbi0anCAGDJTdAa9TlodzRHeiYD87FKmFzS877dPm8Cm0BDvtUhKBUpBvP8+nbHOWFGrgDmLugSZjTGU+mAxtuQpamUFHvinu0BIk3qtjlqouwvbtIqUu8iiZ3Uqu+xKeAANKRy0YVZGLlEb9F3N119tJ/Fxp1p9bXL1qph+CZ25OFbUgZ2s4F+/AyHMUxJlNXKFe3Qean65hC6edhU3zoaKzr/g/wtbhRmcyWbkOa1dJqzr2yKotcPvrnApGhDzgMKFtohg/t7xfMADDVv6sGS5XNpt25Z+MUCmLg4Z9eD7u109jvRV1eu/jgVafqsthWEhXbuMiFgFhKBKGCNZ0dACIfKZSkFZI6FdM7ovJ6aNhSlxZ2169Ybd22rN1UTHeCQWySPcVVOg5taLVpqe+E8Xhnv4hBO5NrzElWwCMLxIdPUSwVStYvtDr8ZytHWzfot50vSnFKIFpTOr9hP4+AJMVmmqJfaJo2MLBft/q2xkztrMv3lQSj3m4+ma9kPDwXIu9uCutjlnhc00jNx9qegi5VfpAjxcG1R+pX4T20az6ByHk/7LPQsANkT31RJq/jAeD9LEuMOy8miha83q4QuvbFaqPK3PY0el/O1LZaXqLsV2aQ0uqH8YX0l4r5NzHdhb+3lYgvpMBO5ytr/EWJiEyNYV518050IUDE=
matrix:
include:
+30 -15
View File
@@ -1,12 +1,26 @@
GNU Bison NEWS
* Noteworthy changes in release 3.3.2 (2019-02-03) [stable]
** Bug fixes
Bison 3.3 failed to generate parsers for grammars with unused nonterminal
symbols.
* Noteworthy changes in release 3.3.1 (2019-01-27) [stable]
** Changes
The option -y/--yacc used to imply -Werror=yacc, which turns uses of Bison
extensions into errors. It now makes them simple warnings (-Wyacc).
* Noteworthy changes in release 3.3 (2019-01-26) [stable]
A new mailing list was created, Bison Announce. It is low traffic, and is
only about announcing new releases and important messages (e.g., polls about
major decisions to make).
A new mailing list was created, Bison Announce. It is low traffic, and is
only about announcing new releases and important messages (e.g., polls
about major decisions to make).
https://lists.gnu.org/mailman/listinfo/bison-announce
https://lists.gnu.org/mailman/listinfo/bison-announce
** Backward incompatible changes
@@ -209,17 +223,18 @@ https://lists.gnu.org/mailman/listinfo/bison-announce
symbol_type (int token, const int&);
symbol_type (int token);
which should be used in a Flex-scanner as follows.
%%
[a-z]+ return yy::parser::symbol_type (ID, yytext);
[0-9]+ return yy::parser::symbol_type (INT, text_to_int (yytext);
":" return yy::parser::symbol_type (:);
<<EOF>> return yy::parser::symbol_type (0);
Correct matching between token types and value types is checked via
'assert'. For instance, 'symbol_type (ID, 42)' would abort (while
'make_ID (42)' would not even compile).
'assert'; for instance, 'symbol_type (ID, 42)' would abort. Named
constructors are preferable, as they offer better type safety (for
instance 'make_ID (42)' would not even compile), but symbol_type
constructors may help when token types are discovered at run-time, e.g.,
[a-z]+ {
if (auto i = lookup_keyword (yytext))
return yy::parser::symbol_type (i);
else
return yy::parser::make_ID (yytext);
}
*** C++: Variadic emplace
@@ -3472,7 +3487,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
LocalWords: Heimbigner AST src ast Makefile srcdir MinGW xxlex XXSTYPE
LocalWords: XXLTYPE strictfp IDEs ffixit fdiagnostics parseable fixits
LocalWords: Wdeprecated yytext Variadic variadic yyrhs yyphrs RCS README
LocalWords: noexcept constexpr ispell american
LocalWords: noexcept constexpr ispell american deprecations
Local Variables:
ispell-dictionary: "american"
+1
View File
@@ -18,6 +18,7 @@ Antonio Silva Correia [email protected]
Arnold Robbins [email protected]
Art Haas [email protected]
Askar Safin [email protected]
Balázs Scheidler [email protected]
Baron Schwartz [email protected]
Ben Pfaff [email protected]
Benoit Perrot [email protected]
+49 -22
View File
@@ -75,48 +75,75 @@ skeletons.
## Symbols
### `b4_symbol(NUM, FIELD)`
In order to unify the handling of the various aspects of symbols (tag, type
name, whether terminal, etc.), bison.exe defines one macro per (token,
field), where field can `has_id`, `id`, etc.: see
src/output.c:prepare_symbols_definitions().
`prepare_symbols_definitions()` in `src/output.c`.
The various FIELDS are:
The macro `b4_symbol(NUM, FIELD)` gives access to the following FIELDS:
- `has_id`: 0 or 1.
- has_id: 0 or 1.
Whether the symbol has an id.
- id: string
If has_id, the id. Guaranteed to be usable as a C identifier.
Prefixed by api.token.prefix if defined.
- tag: string.
- `id`: string
If has_id, the id (prefixed by api.token.prefix if defined), otherwise
defined as empty. Guaranteed to be usable as a C identifier.
- `tag`: string.
A representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
- user_number: integer
- `user_number`: integer
The external number as used by yylex. Can be ASCII code when a character,
some number chosen by bison, or some user number in the case of
%token FOO <NUM>. Corresponds to yychar in yacc.c.
- is_token: 0 or 1
- `is_token`: 0 or 1
Whether this is a terminal symbol.
- number: integer
- `number`: integer
The internal number (computed from the external number by yytranslate).
Corresponds to yytoken in yacc.c. This is the same number that serves as
key in b4_symbol(NUM, FIELD).
- has_type: 0, 1
In bison, symbols are first assigned increasing numbers in order of
appearance (but tokens first, then nterms). After grammar reduction,
unused nterms are then renumbered to appear last (i.e., first tokens, then
used nterms and finally unused nterms). This final number NUM is the one
contained in this field, and it is the one used as key in `b4_symbol(NUM,
FIELD)`.
The code of the rule actions, however, is emitted before we know what
symbols are unused, so they use the original numbers. To avoid confusion,
they actually use "orig NUM" instead of just "NUM". bison also emits
definitions for `b4_symbol(orig NUM, number)` that map from original
numbers to the new ones. `b4_symbol` actually resolves `orig NUM` in the
other case, i.e., `b4_symbol(orig 42, tag)` would return the tag of the
symbols whose original number was 42.
- `has_type`: 0, 1
Whether has a semantic value.
- type_tag: string
- `type_tag`: string
When api.value.type=union, the generated name for the union member.
yytype_INT etc. for symbols that has_id, otherwise yytype_1 etc.
- type
- `type`
If it has a semantic value, its type tag, or, if variant are used,
its type.
In the case of api.value.type=union, type is the real type (e.g. int).
- has_printer: 0, 1
- printer: string
- printer_file: string
- printer_line: integer
- `has_printer`: 0, 1
- `printer`: string
- `printer_file`: string
- `printer_line`: integer
If the symbol has a printer, everything about it.
- has_destructor, destructor, destructor_file, destructor_line
- `has_destructor`, `destructor`, `destructor_file`, `destructor_line`
Likewise.
### b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
### `b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])`
Expansion of $$, $1, $<TYPE-TAG>3, etc.
The semantic value from a given VAL.
@@ -127,14 +154,14 @@ The semantic value from a given VAL.
The result can be used safely, it is put in parens to avoid nasty precedence
issues.
### b4_lhs_value(SYMBOL-NUM, [TYPE])
### `b4_lhs_value(SYMBOL-NUM, [TYPE])`
Expansion of `$$` or `$<TYPE>$`, for symbol `SYMBOL-NUM`.
### b4_rhs_data(RULE-LENGTH, POS)
### `b4_rhs_data(RULE-LENGTH, POS)`
The data corresponding to the symbol `#POS`, where the current rule has
`RULE-LENGTH` symbols on RHS.
### b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
### `b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])`
Expansion of `$<TYPE>POS`, where the current rule has `RULE-LENGTH` symbols
on RHS.
+15 -4
View File
@@ -389,17 +389,28 @@ m4_define([b4_glr_cc_if],
#
# The following macros provide access to symbol related values.
# _b4_symbol(NUM, FIELD)
# ----------------------
# __b4_symbol(NUM, FIELD)
# -----------------------
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
# undefined.
m4_define([_b4_symbol],
m4_define([__b4_symbol],
[m4_indir([b4_symbol($1, $2)])])
# _b4_symbol(NUM, FIELD)
# ----------------------
# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if
# undefined.
m4_define([_b4_symbol],
[m4_ifdef([b4_symbol($1, number)],
[__b4_symbol(m4_indir([b4_symbol($1, number)]), $2)],
[__b4_symbol([$1], [$2])])])
# b4_symbol(NUM, FIELD)
# ---------------------
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if
# undefined. If FIELD = id, prepend the token prefix.
m4_define([b4_symbol],
[m4_case([$2],
+14 -14
View File
@@ -10308,26 +10308,26 @@ See the documentation of @option{--feature=fixit} below for more details.
@item -y
@itemx --yacc
Act more like the traditional Yacc command. This can cause different
diagnostics to be generated, and may change behavior in other minor
ways. Most importantly, imitate Yacc's output file name conventions,
so that the parser implementation file is called @file{y.tab.c}, and
the other outputs are called @file{y.output} and @file{y.tab.h}.
Also, if generating a deterministic parser in C, generate
@code{#define} statements in addition to an @code{enum} to associate
token numbers with token names. Thus, the following shell script can
substitute for Yacc, and the Bison distribution contains such a script
for compatibility with POSIX:
Act more like the traditional @command{yacc} command. This can cause
different diagnostics to be generated (it implies @option{-Wyacc}), and may
change behavior in other minor ways. Most importantly, imitate Yacc's
output file name conventions, so that the parser implementation file is
called @file{y.tab.c}, and the other outputs are called @file{y.output} and
@file{y.tab.h}. Also, if generating a deterministic parser in C, generate
@code{#define} statements in addition to an @code{enum} to associate token
numbers with token names. Thus, the following shell script can substitute
for Yacc, and the Bison distribution contains such a script for
compatibility with POSIX:
@example
#! /bin/sh
bison -y "$@@"
@end example
The @option{-y}/@option{--yacc} option is intended for use with
traditional Yacc grammars. If your grammar uses a Bison extension
like @samp{%glr-parser}, Bison might not be Yacc-compatible even if
this option is specified.
The @option{-y}/@option{--yacc} option is intended for use with traditional
Yacc grammars. If your grammar uses Bison extensions like
@samp{%glr-parser}, Bison might not be Yacc-compatible even if this option
is specified.
@item -W [@var{category}]
@itemx --warnings[=@var{category}]
+3
View File
@@ -15,6 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
SHELL=/bin/sh
export SHELL
me=$(basename "$1" .test)
medir=$(dirname "$1" | sed -e 's,.*examples/,,')
+4 -2
View File
@@ -421,8 +421,10 @@ duplicate_rule_directive (char const *directive,
location first, location second)
{
unsigned i = 0;
complain_indent (&second, complaint, &i, _("only one %s allowed per rule"), directive);
complain_indent (&second, complaint, &i,
_("only one %s allowed per rule"), directive);
i += SUB_INDENT;
complain_indent (&first, complaint, &i, _("previous declaration"));
complain_indent (&first, complaint, &i,
_("previous declaration"));
fixits_register (&second, "");
}
+1 -1
View File
@@ -708,7 +708,7 @@ getargs (int argc, char *argv[])
break;
case 'y':
warning_argmatch ("error=yacc", 0, 6);
warning_argmatch ("yacc", 0, 0);
yacc_loc = command_line_location ();
break;
+9
View File
@@ -38,6 +38,7 @@
#include "muscle-tab.h"
#include "output.h"
#include "reader.h"
#include "reduce.h"
#include "scan-code.h" /* max_left_semantic_context */
#include "scan-skel.h"
#include "symtab.h"
@@ -414,6 +415,14 @@ merger_output (FILE *out)
static void
prepare_symbol_definitions (void)
{
/* Map "orig NUM" to new numbers. See data/README. */
for (symbol_number i = ntokens; i < nsyms + nuseless_nonterminals; ++i)
{
obstack_printf (&format_obstack, "symbol(orig %d, number)", i);
const char *key = obstack_finish0 (&format_obstack);
MUSCLE_INSERT_INT (key, nterm_map ? nterm_map[i - ntokens] : i);
}
for (int i = 0; i < nsyms; ++i)
{
symbol *sym = symbols[i];
+13 -12
View File
@@ -259,22 +259,23 @@ reduce_grammar_tables (void)
| Remove useless nonterminals. |
`------------------------------*/
symbol_number *nterm_map = NULL;
static void
nonterminals_reduce (void)
{
nterm_map = xnmalloc (nvars, sizeof *nterm_map);
/* Map the nonterminals to their new index: useful first, useless
afterwards. Kept for later report. */
symbol_number *nontermmap = xnmalloc (nvars, sizeof *nontermmap);
{
symbol_number n = ntokens;
for (symbol_number i = ntokens; i < nsyms; ++i)
if (bitset_test (V, i))
nontermmap[i - ntokens] = n++;
nterm_map[i - ntokens] = n++;
for (symbol_number i = ntokens; i < nsyms; ++i)
if (!bitset_test (V, i))
{
nontermmap[i - ntokens] = n++;
nterm_map[i - ntokens] = n++;
if (symbols[i]->content->status != used)
complain (&symbols[i]->location, Wother,
_("nonterminal useless in grammar: %s"),
@@ -282,32 +283,30 @@ nonterminals_reduce (void)
}
}
/* Shuffle elements of tables indexed by symbol number. */
{
symbol **symbols_sorted = xnmalloc (nvars, sizeof *symbols_sorted);
for (symbol_number i = ntokens; i < nsyms; ++i)
symbols[i]->content->number = nontermmap[i - ntokens];
symbols[i]->content->number = nterm_map[i - ntokens];
for (symbol_number i = ntokens; i < nsyms; ++i)
symbols_sorted[nontermmap[i - ntokens] - ntokens] = symbols[i];
symbols_sorted[nterm_map[i - ntokens] - ntokens] = symbols[i];
for (symbol_number i = ntokens; i < nsyms; ++i)
symbols[i] = symbols_sorted[i - ntokens];
free (symbols_sorted);
}
/* Update nonterminal numbers in the RHS of the rules. LHS are
pointers to the symbol structure, they don't need renumbering. */
{
for (rule_number r = 0; r < nrules; ++r)
for (item_number *rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp)
if (ISVAR (*rhsp))
*rhsp = symbol_number_as_item_number (nontermmap[*rhsp
- ntokens]);
accept->content->number = nontermmap[accept->content->number - ntokens];
*rhsp = symbol_number_as_item_number (nterm_map[*rhsp - ntokens]);
accept->content->number = nterm_map[accept->content->number - ntokens];
}
nsyms -= nuseless_nonterminals;
nvars -= nuseless_nonterminals;
free (nontermmap);
}
@@ -433,4 +432,6 @@ reduce_free (void)
bitset_free (V);
bitset_free (V1);
bitset_free (P);
free (nterm_map);
nterm_map = NULL;
}
+5
View File
@@ -32,6 +32,11 @@ bool reduce_nonterminal_useless_in_grammar (const sym_content *sym);
void reduce_free (void);
/** Map initial nterm numbers to the new ones. Built by
* reduce_grammar. Size nvars + nuseless_nonterminals. */
extern symbol_number *nterm_map;
extern unsigned nuseless_nonterminals;
extern unsigned nuseless_productions;
#endif /* !REDUCE_H_ */
+4 -2
View File
@@ -648,7 +648,7 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
untyped_var_seen = true;
}
obstack_printf (&obstack_for_string, "]b4_lhs_value(%d, ",
obstack_printf (&obstack_for_string, "]b4_lhs_value(orig %d, ",
sym->content.sym->content->number);
obstack_quote (&obstack_for_string, type_name);
obstack_sgrow (&obstack_for_string, ")[");
@@ -677,7 +677,9 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
"]b4_rhs_value(%d, %d, ",
effective_rule_length, n);
if (sym)
obstack_printf (&obstack_for_string, "%d, ", sym->content.sym->content->number);
obstack_printf (&obstack_for_string, "%s%d, ",
sym->content.sym->content->class == nterm_sym ? "orig " : "",
sym->content.sym->content->number);
else
obstack_sgrow (&obstack_for_string, "[], ");
+9 -9
View File
@@ -1402,15 +1402,15 @@ without_period: "WITHOUT.PERIOD";
AT_BISON_OPTION_POPDEFS
# POSIX Yacc accept periods, but not dashes.
AT_BISON_CHECK([--yacc input.y], [1], [],
[[input.y:1.1-5: error: POSIX Yacc does not support %code [-Werror=yacc]
input.y:9.8-16: error: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Werror=yacc]
input.y:10.21-34: error: POSIX Yacc does not support string literals [-Werror=yacc]
input.y:12.23-38: error: POSIX Yacc does not support string literals [-Werror=yacc]
input.y:13.1-5: error: POSIX Yacc does not support %code [-Werror=yacc]
input.y:20.8-16: error: POSIX Yacc forbids dashes in symbol names: with-dash [-Werror=yacc]
input.y:22.15-28: error: POSIX Yacc does not support string literals [-Werror=yacc]
input.y:24.17-32: error: POSIX Yacc does not support string literals [-Werror=yacc]
AT_BISON_CHECK([--yacc input.y], [], [],
[[input.y:1.1-5: warning: POSIX Yacc does not support %code [-Wyacc]
input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Wyacc]
input.y:10.21-34: warning: POSIX Yacc does not support string literals [-Wyacc]
input.y:12.23-38: warning: POSIX Yacc does not support string literals [-Wyacc]
input.y:13.1-5: warning: POSIX Yacc does not support %code [-Wyacc]
input.y:20.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc]
input.y:22.15-28: warning: POSIX Yacc does not support string literals [-Wyacc]
input.y:24.17-32: warning: POSIX Yacc does not support string literals [-Wyacc]
]])
# Dashes are fine for GNU Bison.
+82
View File
@@ -199,6 +199,88 @@ AT_CLEANUP
## --------------- ##
## Useless Parts. ##
## --------------- ##
AT_SETUP([Useless Parts])
# We used to emit code that used symbol numbers before the useless
# symbol elimination, hence before the renumbering of the useful
# symbols. As a result, the evaluation of the skeleton failed because
# it used non existing symbol numbers. Which is the happy scenario:
# we could use numbers of other existing symbols...
# http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00044.html
AT_BISON_OPTION_PUSHDEFS
AT_DATA([[input.y]],
[[%code {
]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[
}
%union { void* ptr; }
%type <ptr> used1
%type <ptr> used2
%%
start
: used1
;
used1
: used2 { $$ = $1; }
;
unused
: used2
;
used2
: { $$ = YY_NULLPTR; }
;
]])
AT_BISON_CHECK([[-fcaret -rall -o input.c input.y]], 0, [],
[[input.y: warning: 1 nonterminal useless in grammar [-Wother]
input.y: warning: 1 rule useless in grammar [-Wother]
input.y:18.1-6: warning: nonterminal useless in grammar: unused [-Wother]
unused
^~~~~~
]])
AT_CHECK([[sed -n '/^State 0/q;/^$/!p' input.output]], 0,
[[Nonterminals useless in grammar
unused
Rules useless in grammar
4 unused: used2
Grammar
0 $accept: start $end
1 start: used1
2 used1: used2
3 used2: %empty
Terminals, with rules where they appear
$end (0) 0
error (256)
Nonterminals, with rules where they appear
$accept (3)
on left: 0
start (4)
on left: 1, on right: 0
used1 <ptr> (5)
on left: 2, on right: 1
used2 <ptr> (6)
on left: 3, on right: 2
]])
# Make sure the generated parser is correct.
AT_COMPILE([input.o])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
## ------------------- ##
## Reduced Automaton. ##
## ------------------- ##