Compare commits

...
20 Commits
Author SHA1 Message Date
Akim Demaille a0bc06b703 version 3.7.2
* NEWS: Record release date.
2020-09-05 18:06:16 +02:00
Akim Demaille 5e33dfe59d build: disable syntax-check warning
error_message_uppercase
etc/bench.pl.in-419-static int yylex (@{[is_pure (@directive) ? "YYSTYPE *yylvalp" : "void"]});

* cfg.mk: here.
2020-09-05 17:59:56 +02:00
Akim Demaille 2a4e9a358f gnulib: update 2020-09-05 17:44:38 +02:00
Akim Demaille f7b642cff7 build: fix incorrect dependencies
Commit af000bab11 ("doc: work around
Texinfo 6.7 bug"), published in 3.4.91, added a dependency on the
"all" target.

This is a super bad idea, since "make all" will run this
target *before* "all", which builds bison.  It turns out that this new
dependency actually needed bison to be built.  So all the regular
process (i) build $(BUILT_SOURCES) and then (ii) build bison, was
wrecked since some of the $(BUILT_SOURCES) depended on bison...

It was "easy" to see in the logs of "make V=1" because we were
building bison files (such as src/files.o) *before* displaying the
banner for "all-recursive".  With this fix, we finally get again the
proper sequence:

    rm -f examples/c/reccalc/scan.stamp examples/c/reccalc/scan.stamp.tmp
    /opt/local/libexec/gnubin/mkdir -p examples/c/reccalc
    touch examples/c/reccalc/scan.stamp.tmp
    flex   -oexamples/c/reccalc/scan.c --header=examples/c/reccalc/scan.h ./examples/c/reccalc/scan.l
    mv examples/c/reccalc/scan.stamp.tmp examples/c/reccalc/scan.stamp
    rm -f lib/fcntl.h-t lib/fcntl.h && \
    { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
      ...
    } > lib/fcntl.h-t && \
    mv lib/fcntl.h-t lib/fcntl.h
    ...
    mv -f lib/alloca.h-t lib/alloca.h
    make  all-recursive

Reported by Mingli Yu <[email protected]>.
https://github.com/akimd/bison/issues/31
https://lists.gnu.org/r/bison-patches/2020-05/msg00055.html

Reported by Claudio Calvelli <[email protected]>.
https://lists.gnu.org/r/bug-bison/2020-09/msg00001.html
https://bugs.gentoo.org/716516

* doc/local.mk (all): Rename as...
(all-local): this.
So that we don't compete with BUILT_SOURCES.
2020-09-05 17:42:20 +02:00
Akim Demaille 3da17724ad doc: updates
* NEWS, TODO: here.
2020-09-02 21:37:23 +02:00
Akim Demaille 68e3e442f9 gnulib: update 2020-08-30 17:32:43 +02:00
Akim Demaille e432619d11 tests: beware of sed portability issues
Reported by David Laxer <[email protected]>.
https://lists.gnu.org/r/bug-bison/2020-08/msg00027.html

* tests/output.at: Don't use + with sed.
While at it, fix a quotation problem hidden by the use of '#'.
2020-08-30 17:16:18 +02:00
Akim Demaille a1b7fef045 c: always use YYMALLOC/YYFREE
Reported by Kovalex <[email protected]>.
https://lists.gnu.org/r/bug-bison/2020-08/msg00015.html

* data/skeletons/yacc.c: Don't make direct calls to malloc/free.
* tests/calc.at: Check it.
2020-08-30 10:05:18 +02:00
Akim Demaille 067e35a8be build: beware of POSIX mode
Reported by Dennis Clarke.
https://lists.gnu.org/r/bug-bison/2020-08/msg00013.html

* examples/d/local.mk, examples/java/calc/local.mk,
* examples/java/simple/local.mk: Pass bison's options before its
argument, in case we're in POSIX mode.
2020-08-30 09:38:05 +02:00
Akim Demaille 0522047c96 doc: history of api.prefix
Reported by Matthew Fernandez <[email protected]>.
https://lists.gnu.org/r/help-bison/2020-08/msg00015.html

* doc/bison.texi (api.prefix): We move to {} in 3.0.
2020-08-30 09:29:00 +02:00
Akim Demaille 3724b50ef9 CI: intel moved the script for ICC
* .travis.yml: Adjust.
2020-08-11 07:18:48 +02:00
Akim Demaille b801b7b670 fix: unterminated \-escape
An assertion failed when the last character is a '\' and we're in a
character or a string.
Reported by Agency for Defense Development.
https://lists.gnu.org/r/bug-bison/2020-08/msg00009.html

* src/scan-gram.l: Catch unterminated escapes.
* tests/input.at (Unexpected end of file): New.
2020-08-08 07:53:33 +02:00
Akim Demaille b7aab2dbad fix: crash when redefining the EOF token
Reported by Agency for Defense Development.
https://lists.gnu.org/r/bug-bison/2020-08/msg00008.html

On an empty such as

    %token FOO
           BAR
           FOO 0
    %%
    input: %empty

we crash because when we find FOO 0, we decrement ntokens (since FOO
was discovered to be EOF, which is already known to be a token, so we
increment ntokens for it, and need to cancel this).  This "works well"
when EOF is properly defined in one go, but here it is first defined
and later only assign token code 0.  In the meanwhile BAR was given
the token number that we just decremented.

To fix this, assign symbol numbers after parsing, not during parsing,
so that we also saw all the explicit token codes.  To maintain the
current numbers (I'd like to keep no difference in the output, not
just equivalence), we need to make sure the symbols are numbered in
the same order: that of appearance in the source file.  So we need the
locations to be correct, which was almost the case, except for nterms
that appeared several times as LHS (i.e., several times as "foo:
...").  Fixing the use of location_of_lhs sufficed (it appears it was
intended for this use, but its implementation was unfinished: it was
always set to "false" only).

* src/symtab.c (symbol_location_as_lhs_set): Update location_of_lhs.
(symbol_code_set): Remove broken hack that decremented ntokens.
(symbol_class_set, dummy_symbol_get): Don't set number, ntokens and
nnterms.
(symbol_check_defined): Do it.
(symbols): Don't count nsyms here.
Actually, don't count nsyms at all: let it be done in...
* src/reader.c (check_and_convert_grammar): here.  Define nsyms from
ntokens and nnterms after parsing.
* tests/input.at (EOF redeclared): New.

* examples/c/bistromathic/bistromathic.test: Adjust the traces: in
"%nterm <double> exp %% input: ...", exp used to be numbered before
input.
2020-08-07 07:30:06 +02:00
Akim Demaille 89e42ffb4b style: fix missing space before paren
* cfg.mk (_space_before_paren_exempt): Be less laxist.
* src/output.c, src/reader.c: Fix space before paren issues.
Pacify the warnings where applicable.
2020-08-07 07:30:06 +02:00
Akim Demaille 6aae4a7378 style: fix comments and more debug trace
* src/location.c, src/symtab.h, src/symtab.c: here.
2020-08-07 07:30:06 +02:00
Akim Demaille 7d4a4300c2 style: more uses of const
* src/symtab.c: here.
2020-08-07 07:30:06 +02:00
Akim Demaille 31d4ec28bd bench: fix support for pure parser
* etc/bench.pl.in (is_pure): New.
(generate_grammar_calc): Use code provides where needed.
Use is_pure to call yylex properly.
Coding style fixes.
2020-08-07 07:29:16 +02:00
Akim Demaille 0a5bfb4fda portability: multiple typedefs
Older versions of GCC (4.1.2 here) don't like repeated typedefs.

      CC       src/bison-parse-simulation.o
    src/parse-simulation.c:61: error: redefinition of typedef 'parse_state'
    src/parse-simulation.h:74: error: previous declaration of 'parse_state' was here
    make: *** [Makefile:7876: src/bison-parse-simulation.o] Error 1

Reported by Nelson H. F. Beebe.

* src/parse-simulation.c (parse_state): Don't typedef,
parse-simulation.h did it already.
2020-08-03 07:30:35 +02:00
Akim Demaille 12d0b15679 style: revert "avoid warnings with GCC 4.6"
This reverts commit d0bec3175f (which
should have read "We have a clash...", not "With have a clash...").
Now that `max()` was renamed `max_int()`, we can use `max` again, as
elsewhere in the code.

* src/counterexample.c (visited_hasher): Alpha reconversion.
2020-08-02 10:20:23 +02:00
Akim Demaille cb7dcb011e maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2020-08-02 09:32:34 +02:00
30 changed files with 301 additions and 114 deletions
+1 -1
View File
@@ -1 +1 @@
3.7
3.7.1
+2 -1
View File
@@ -50,6 +50,7 @@ jobs:
- make -j2 dist-xz
# Can help understanding why we get "dirty" tarballs.
- git status
- git diff
- dist=$(echo bison*.xz)
# Unfortunately we cannot deterministically know the name of the tarball without the full
@@ -129,7 +130,7 @@ jobs:
- CC=icc
- CXX=icpc
install:
- source /opt/intel/inteloneapi/compiler/latest/env/vars.sh
- source /opt/intel/oneapi/compiler/latest/env/vars.sh
addons:
apt:
sources:
+25 -1
View File
@@ -1,5 +1,28 @@
GNU Bison NEWS
* Noteworthy changes in release 3.7.2 (2020-09-05) [stable]
This release of Bison fixes all known bugs reported for Bison in MITRE's
Common Vulnerabilities and Exposures (CVE) system. These vulnerabilities
are only about bison-the-program itself, not the generated code.
Although these bugs are typically irrelevant to how Bison is used, they
are worth fixing if only to give users peace of mind.
There is no known vulnerability in the generated parsers.
** Bug fixes
Fix concurrent build issues (introduced in Bison 3.5).
Push parsers always use YYMALLOC/YYFREE (no direct calls to malloc/free).
Fix portability issues of the test suite, and of bison itself.
Some unlikely crashes found by fuzzing have been fixed. This is only
about bison itself, not the generated parsers.
* Noteworthy changes in release 3.7.1 (2020-08-02) [stable]
** Bug fixes
@@ -554,7 +577,8 @@ GNU Bison NEWS
\005) with incorrect styling. Fixes for similar issues with unexpectedly
short lines (e.g., the file was changed between parsing and diagnosing).
Several unlikely crashes found by fuzzing have been fixed.
Some unlikely crashes found by fuzzing have been fixed. This is only
about bison itself, not the generated parsers.
* Noteworthy changes in release 3.5.2 (2020-02-13) [stable]
+9 -1
View File
@@ -1,4 +1,12 @@
* Bison 3.7
* Soon
** gnulib
Bruno notes:
> I haven't looked deeply, but it strikes me that gnulib/lib/bitset/array.c
> does not make use of the 'ffsl' function, nor or the 'integer_length_l'
> function. Maybe because in Bison, all bitsets are so dense that it does
> not give a performance advantage?
** Cex
*** Improve gnulib
Don't do this (counterexample.c):
+2 -1
View File
@@ -126,7 +126,7 @@ _sed_rm_comments_q = $(subst ','\'',$(_sed_remove_comments))
_space_before_paren_exempt =? \\n\\$$
_space_before_paren_exempt = \
(^ *\#|(LA)?LR\([01]\)|percent_(code|define)|b4_syncline|m4_(define|init)|symbol)
(^ *\#|(LA)?LR\([01]\)|percent_(code|define)|b4_syncline|m4_(define|init))
# Ensure that there is a space before each open parenthesis in C code.
sc_space_before_open_paren:
@if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
@@ -156,6 +156,7 @@ exclude = \
$(call exclude, \
bindtextdomain=^lib/main.c$$ \
cast_of_argument_to_free=^src/muscle-tab.c$$ \
error_message_uppercase=etc/bench.pl.in$$ \
po_check=^tests|(^po/POTFILES.in|.md)$$ \
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
program_name=^lib/main.c$$ \
+2 -2
View File
@@ -1486,7 +1486,7 @@ yypstate_new (void)
yypstate *yyps;]b4_pure_if([], [[
if (yypstate_allocated)
return YY_NULLPTR;]])[
yyps = YY_CAST (yypstate *, malloc (sizeof *yyps));
yyps = YY_CAST (yypstate *, YYMALLOC (sizeof *yyps));
if (!yyps)
return YY_NULLPTR;]b4_pure_if([], [[
yypstate_allocated = 1;]])[
@@ -1515,7 +1515,7 @@ yypstate_delete (yypstate *yyps)
#endif]b4_lac_if([[
if (yyes != yyesa)
YYSTACK_FREE (yyes);]])[
free (yyps);]b4_pure_if([], [[
YYFREE (yyps);]b4_pure_if([], [[
yypstate_allocated = 0;]])[
}
}
+4 -1
View File
@@ -6296,7 +6296,10 @@ Introduced in Bison 3.3 to replace @code{parser_class_name}.
@item Default Value: @code{YY} for Java, @code{yy} otherwise.
@item History: introduced in Bison 2.6
@item History:
introduced in Bison 2.6, with its argument in double quotes. Uses braces
since Bison 3.0 (double quotes are still supported for backward
compatibility).
@end itemize
@end deffn
+1 -1
View File
@@ -57,7 +57,7 @@ MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI)
# Fix Info's @code in @deftype
# https://lists.gnu.org/archive/html/help-texinfo/2019-11/msg00004.html
all: $(srcdir)/$(%C%_bison).info.bak
all-local: $(srcdir)/$(%C%_bison).info.bak
$(srcdir)/$(%C%_bison).info.bak: $(srcdir)/$(%C%_bison).info
$(AM_V_GEN) $(PERL) -pi.bak -0777 \
-e 's{(^ --.*\n(?: {10}.*\n)*)}' \
+41 -29
View File
@@ -185,13 +185,13 @@ my $verbose = 1;
=over 4
=item C<verbose($level, $message)>
=item C<verbose ($level, $message)>
Report the C<$message> is C<$level> E<lt>= C<$verbose>.
=cut
sub verbose($$)
sub verbose ($$)
{
my ($level, $message) = @_;
print STDERR $message
@@ -201,13 +201,13 @@ sub verbose($$)
######################################################################
=item C<directives($bench, @directive)>
=item C<directives ($bench, @directive)>
Format the list of directives for Bison for bench named C<$bench>.
=cut
sub directives($@)
sub directives ($@)
{
my ($bench, @directive) = @_;
my $res = "/* Directives for bench '$bench'. */\n";
@@ -218,6 +218,27 @@ sub directives($@)
######################################################################
=item C<is_pure (@directive)>
Whether api.pure is set.
=cut
sub is_pure (@)
{
my (@directive) = @_;
for my $dir (@directive)
{
if ($dir =~ /\A%define api.pure/)
{
return 1;
}
}
return 0;
}
######################################################################
=item C<generate_grammar_triangular ($base, $max, @directive)>
Create a large triangular grammar which looks like :
@@ -389,18 +410,14 @@ sub generate_grammar_calc ($$@)
%define api.value.type union
$directives
%{
%code provides {
static int power (int base, int exponent);
/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
static void yyerror (const char *s);
#if YYPURE
static int yylex (YYSTYPE* yylvalp);
#else
static int yylex (void);
#endif
%}
static int yylex (@{[is_pure (@directive) ? "YYSTYPE *yylvalp" : "void"]});
}
/* Bison Declarations */
%token
@@ -467,12 +484,7 @@ yyerror (const char *s)
}
static int
#if YYPURE
# define yylval (*yylvalp)
yylex (YYSTYPE* yylvalp)
#else
yylex (void)
#endif
yylex (@{[is_pure (@directive) ? "YYSTYPE *yylvalp" : "void"]})
{
int c;
@@ -498,7 +510,7 @@ yylex (void)
case '5': case '6': case '7': case '8': case '9':
{
int nchars = 0;
int n = sscanf (input - 1, "%d%n", &yylval.NUM, &nchars);
int n = sscanf (input - 1, "%d%n", &@{[is_pure (@directive) ? "yylvalp->" : "yylval."]}NUM, &nchars);
assert (n == 1);
input += nchars - 1;
return NUM;
@@ -506,7 +518,7 @@ yylex (void)
default:
yyerror ("error: invalid character");
return yylex ();
return yylex (@{[is_pure (@directive) ? "yylvalp" : ""]});
}
}
EOF
@@ -592,10 +604,10 @@ $directives
// Prototype of the yylex function providing subsequent tokens.
static
#if USE_TOKEN_CTOR
yy::parser::symbol_type yylex();
yy::parser::symbol_type yylex ();
#else
yy::parser::token_type yylex(yy::parser::semantic_type* yylvalp,
yy::parser::location_type* yyllocp);
yy::parser::token_type yylex (yy::parser::semantic_type *yylvalp,
yy::parser::location_type *yyllocp);
#endif
// Conversion to string.
@@ -618,8 +630,8 @@ EOF
print $out <<'EOF';
%token <std::string> TEXT
%token <int> NUMBER
%printer { std::cerr << "Number: " << $$; } <int>
%printer { std::cerr << "Text: " << $$; } <std::string>
%printer { yyo << "Number: " << $$; } <int>
%printer { yyo << "Text: " << $$; } <std::string>
%type <std::string> text result
%%
@@ -641,8 +653,8 @@ EOF
%union {int ival; std::string* sval;}
%token <sval> TEXT
%token <ival> NUMBER
%printer { std::cerr << "Number: " << $$; } <ival>
%printer { std::cerr << "Text: " << *$$; } <sval>
%printer { yyo << "Number: " << $$; } <ival>
%printer { yyo << "Text: " << *$$; } <sval>
%type <sval> text result
%%
@@ -664,10 +676,10 @@ EOF
static
#if USE_TOKEN_CTOR
yy::parser::symbol_type yylex()
yy::parser::symbol_type yylex ()
#else
yy::parser::token_type yylex(yy::parser::semantic_type* yylvalp,
yy::parser::location_type* yyllocp)
yy::parser::token_type yylex (yy::parser::semantic_type *yylvalp,
yy::parser::location_type *yyllocp)
#endif
{
typedef yy::parser::location_type location_type;
+10 -10
View File
@@ -251,29 +251,29 @@ err: Next token is token ) (1.4: )
err: Shifting token ) (1.4: )
err: Entering state 20
err: Stack now 0 2 10 20
err: Reducing stack by rule 15 (line 151):
err: Reducing stack by rule XX (line XXX):
err: $1 = token ( (1.1: )
err: $2 = token error (1.2-3: )
err: $3 = token ) (1.4: )
err: -> $$ = nterm exp (1.1-4: 666)
err: Entering state 7
err: Stack now 0 7
err: Entering state 8
err: Stack now 0 8
err: Return for a new token:
err: Reading a token
err: Now at end of input.
err: LAC: initial context established for end of file
err: LAC: checking lookahead end of file: R2 G8 S19
err: Reducing stack by rule 2 (line 126):
err: LAC: checking lookahead end of file: R2 G7 S14
err: Reducing stack by rule XX (line XXX):
err: $1 = nterm exp (1.1-4: 666)
err: -> $$ = nterm input (1.1-4: )
err: Entering state 8
err: Stack now 0 8
err: Entering state 7
err: Stack now 0 7
err: Now at end of input.
err: Shifting token end of file (1.5: )
err: LAC: initial context discarded due to shift
err: Entering state 19
err: Stack now 0 8 19
err: Stack now 0 8 19
err: Entering state 14
err: Stack now 0 7 14
err: Stack now 0 7 14
err: Cleanup: popping token end of file (1.5: )
err: Cleanup: popping nterm input (1.1-4: )' -p
+1 -1
View File
@@ -27,7 +27,7 @@ EXTRA_DIST += %D%/calc.test
%D%/calc.d: %D%/calc.y $(dependencies)
$(AM_V_GEN)$(MKDIR_P) %D%
$(AM_V_at)$(BISON) $(srcdir)/%D%/calc.y -o $@
$(AM_V_at)$(BISON) -o $@ $(srcdir)/%D%/calc.y
%D%/calc: %D%/calc.d
$(AM_V_GEN) $(DC) $(DCFLAGS) -of$@ %D%/calc.d
+1 -1
View File
@@ -27,7 +27,7 @@ EXTRA_DIST += %D%/Calc.test
%D%/Calc.java: %D%/Calc.y $(dependencies)
$(AM_V_GEN)$(MKDIR_P) %D%
$(AM_V_at)$(BISON) $(srcdir)/%D%/Calc.y -o $@
$(AM_V_at)$(BISON) -o $@ $(srcdir)/%D%/Calc.y
%D%/Calc.class: %D%/Calc.java
$(AM_V_GEN) $(SHELL) $(top_builddir)/javacomp.sh %D%/Calc.java
+1 -1
View File
@@ -27,7 +27,7 @@ EXTRA_DIST += %D%/Calc.test
%D%/Calc.java: %D%/Calc.y $(dependencies)
$(AM_V_GEN)$(MKDIR_P) %D%
$(AM_V_at)$(BISON) $(srcdir)/%D%/Calc.y -o $@
$(AM_V_at)$(BISON) -o $@ $(srcdir)/%D%/Calc.y
%D%/Calc.class: %D%/Calc.java
$(AM_V_GEN) $(SHELL) $(top_builddir)/javacomp.sh %D%/Calc.java
+1 -1
Submodule gnulib updated: 37b6f12946...a83f488ba4
+2
View File
@@ -336,9 +336,11 @@
/sys_types.in.h
/sys_wait.in.h
/sysexits.in.h
/termios.h
/termios.in.h
/textstyle.h
/textstyle.in.h
/thread-optim.h
/time.h
/time.in.h
/timespec.c
+2
View File
@@ -67,6 +67,7 @@
/intlmacosx.m4
/intmax.m4
/intmax_t.m4
/inttypes-pri.m4
/inttypes.m4
/inttypes_h.m4
/isnan.m4
@@ -127,6 +128,7 @@
/open.m4
/pathmax.m4
/perror.m4
/pid_t.m4
/pipe2.m4
/po.m4
/posix_spawn.m4
+3 -3
View File
@@ -712,10 +712,10 @@ ssb_equals (const search_state_bundle *s1, const search_state_bundle *s2)
typedef gl_list_t ssb_list;
static size_t
visited_hasher (const search_state *ss, size_t maximum)
visited_hasher (const search_state *ss, size_t max)
{
return (parse_state_hasher (ss->states[0], maximum)
+ parse_state_hasher (ss->states[1], maximum)) % maximum;
return (parse_state_hasher (ss->states[0], max)
+ parse_state_hasher (ss->states[1], max)) % max;
}
static bool
+3 -1
View File
@@ -155,7 +155,9 @@ int
location_print (location loc, FILE *out)
{
int res = 0;
if (trace_flag & trace_locations)
if (location_empty (loc))
res += fprintf (out, "(empty location)");
else if (trace_flag & trace_locations)
{
res += boundary_print (&loc.start, out);
res += fprintf (out, "-");
+4 -4
View File
@@ -249,7 +249,7 @@ prepare_symbol_names (char const *muscle_name)
if (i)
obstack_1grow (&format_obstack, ' ');
if (translatable)
obstack_sgrow (&format_obstack, "]b4_symbol_translate([");
obstack_sgrow (&format_obstack, "]b4_symbol_translate""([");
obstack_escape (&format_obstack, cp);
if (translatable)
obstack_sgrow (&format_obstack, "])[");
@@ -554,7 +554,7 @@ 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);
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);
}
@@ -565,12 +565,12 @@ prepare_symbol_definitions (void)
const char *key;
#define SET_KEY(Entry) \
obstack_printf (&format_obstack, "symbol(%d, %s)", \
obstack_printf (&format_obstack, "symbol""(%d, %s)", \
i, Entry); \
key = obstack_finish0 (&format_obstack);
#define SET_KEY2(Entry, Suffix) \
obstack_printf (&format_obstack, "symbol(%d, %s_%s)", \
obstack_printf (&format_obstack, "symbol""(%d, %s_%s)", \
i, Entry, Suffix); \
key = obstack_finish0 (&format_obstack);
+1 -2
View File
@@ -3147,8 +3147,7 @@ char_name (char c)
}
}
static
void
static void
current_lhs (symbol *sym, location loc, named_ref *ref)
{
current_lhs_symbol = sym;
+1 -2
View File
@@ -1158,8 +1158,7 @@ char_name (char c)
}
}
static
void
static void
current_lhs (symbol *sym, location loc, named_ref *ref)
{
current_lhs_symbol = sym;
+2 -2
View File
@@ -28,7 +28,7 @@
#include "lssi.h"
#include "nullable.h"
typedef struct parse_state
struct parse_state
{
// Path of state-items the parser has traversed.
struct si_chunk
@@ -58,7 +58,7 @@ typedef struct parse_state
// Causes chunk contents to be freed when the reference count is
// one. Used when only the chunk metadata will be needed.
bool free_contents_early;
} parse_state;
};
static void
+7 -4
View File
@@ -406,8 +406,8 @@ grammar_midrule_action (void)
action. Create the MIDRULE. */
location dummy_loc = current_rule->action_props.location;
symbol *dummy = dummy_symbol_get (dummy_loc);
symbol_type_set(dummy,
current_rule->action_props.type, current_rule->action_props.location);
symbol_type_set (dummy,
current_rule->action_props.type, current_rule->action_props.location);
symbol_list *midrule = symbol_list_sym_new (dummy, dummy_loc);
/* Remember named_ref of previous action. */
@@ -815,8 +815,11 @@ check_and_convert_grammar (void)
grammar = p;
}
aver (nsyms <= SYMBOL_NUMBER_MAXIMUM);
aver (nsyms == ntokens + nnterms);
if (SYMBOL_NUMBER_MAXIMUM - nnterms < ntokens)
complain (NULL, fatal, "too many symbols in input grammar (limit is %d)",
SYMBOL_NUMBER_MAXIMUM);
nsyms = ntokens + nnterms;
/* Assign the symbols their symbol numbers. */
symbols_pack ();
+13 -5
View File
@@ -567,6 +567,8 @@ eqopt ({sp}=)?
_("POSIX Yacc does not support string literals"));
RETURN_VALUE (STRING, last_string);
}
<<EOF>> unexpected_eof (token_start, "\"");
"\n" unexpected_newline (token_start, "\"");
}
<SC_ESCAPED_TSTRING>
@@ -580,13 +582,10 @@ eqopt ({sp}=)?
_("POSIX Yacc does not support string literals"));
RETURN_VALUE (TSTRING, last_string);
}
<<EOF>> unexpected_eof (token_start, "\")");
"\n" unexpected_newline (token_start, "\")");
}
<SC_ESCAPED_STRING,SC_ESCAPED_TSTRING>
{
<<EOF>> unexpected_eof (token_start, "\"");
"\n" unexpected_newline (token_start, "\"");
}
/*----------------------------------------------------------.
@@ -692,6 +691,15 @@ eqopt ({sp}=)?
p);
STRING_1GROW ('?');
}
"\\" {
// None of the other rules matched: the last character of this
// file is "\". But Flex does not support "\\<<EOF>>".
unexpected_eof (token_start,
YY_START == SC_ESCAPED_CHARACTER ? "?'"
: YY_START == SC_ESCAPED_STRING ? "?\""
: "?\")");
}
}
/*--------------------------------------------.
+28 -31
View File
@@ -137,11 +137,6 @@ symbol_new (uniqstr tag, location loc)
res->alias = NULL;
res->content = sym_content_new (res);
res->is_alias = false;
if (nsyms == SYMBOL_NUMBER_MAXIMUM)
complain (NULL, fatal, _("too many symbols in input grammar (limit is %d)"),
SYMBOL_NUMBER_MAXIMUM);
nsyms++;
return res;
}
@@ -182,11 +177,11 @@ symbol_free (void *ptr)
*/
static void
symbols_sort (symbol **first, symbol **second)
symbols_sort (const symbol **first, const symbol **second)
{
if (0 < location_cmp ((*first)->location, (*second)->location))
{
symbol* tmp = *first;
const symbol* tmp = *first;
*first = *second;
*second = tmp;
}
@@ -243,7 +238,11 @@ semantic_type_new (uniqstr tag, const location *loc)
| Print a symbol. |
`-----------------*/
#define SYMBOL_ATTR_PRINT(Attr) \
#define SYMBOL_INT_ATTR_PRINT(Attr) \
if (s->content) \
fprintf (f, " %s = %d", #Attr, s->content->Attr)
#define SYMBOL_STR_ATTR_PRINT(Attr) \
if (s->content && s->content->Attr) \
fprintf (f, " %s { %s }", #Attr, s->content->Attr)
@@ -264,7 +263,11 @@ symbol_print (symbol const *s, FILE *f)
: c == nterm_sym ? "nterm"
: NULL, /* abort. */
s->tag);
SYMBOL_ATTR_PRINT (type_name);
putc (' ', f);
location_print (s->location, f);
SYMBOL_INT_ATTR_PRINT (code);
SYMBOL_INT_ATTR_PRINT (number);
SYMBOL_STR_ATTR_PRINT (type_name);
SYMBOL_CODE_PRINT (destructor);
SYMBOL_CODE_PRINT (printer);
}
@@ -371,7 +374,7 @@ symbol_from_uniqstr_fuzzy (const uniqstr key)
}
static void
complain_symbol_undeclared (symbol *sym)
complain_symbol_undeclared (const symbol *sym)
{
assert (sym->content->status != declared);
const symbol *best = symbol_from_uniqstr_fuzzy (sym->tag);
@@ -398,7 +401,10 @@ void
symbol_location_as_lhs_set (symbol *sym, location loc)
{
if (!sym->location_of_lhs)
sym->location = loc;
{
sym->location = loc;
sym->location_of_lhs = true;
}
}
@@ -548,10 +554,6 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring)
if (class == token_sym && s->class == pct_type_sym)
complain_pct_type_on_token (&sym->location);
if (class == nterm_sym && s->class != nterm_sym)
s->number = nnterms++;
else if (class == token_sym && s->number == NUMBER_UNDEFINED)
s->number = ntokens++;
s->class = class;
if (declaring)
@@ -573,9 +575,9 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring)
}
/*------------------------------------------------.
| Set the USER_TOKEN_NUMBER associated with SYM. |
`------------------------------------------------*/
/*----------------------------.
| Set the token code of SYM. |
`----------------------------*/
void
symbol_code_set (symbol *sym, int code, location loc)
@@ -598,10 +600,6 @@ symbol_code_set (symbol *sym, int code, location loc)
if (code == 0 && !eoftoken)
{
eoftoken = sym->content->symbol;
/* It is always mapped to 0, so it was already counted in
NTOKENS. */
if (eoftoken->content->number != NUMBER_UNDEFINED)
--ntokens;
eoftoken->content->number = 0;
}
}
@@ -621,9 +619,11 @@ symbol_check_defined (symbol *sym)
{
complain_symbol_undeclared (sym);
s->class = nterm_sym;
s->number = nnterms++;
}
if (s->number == NUMBER_UNDEFINED)
s->number = s->class == token_sym ? ntokens++ : nnterms++;
if (s->class == token_sym
&& sym->tag[0] == '"'
&& !sym->is_alias)
@@ -742,7 +742,7 @@ symbol_pack (symbol *sym)
}
static void
complain_code_redeclared (int num, symbol *first, symbol *second)
complain_code_redeclared (int num, const symbol *first, const symbol *second)
{
symbols_sort (&first, &second);
complain (&second->location, complaint,
@@ -758,13 +758,11 @@ complain_code_redeclared (int num, symbol *first, symbol *second)
`-------------------------------------------------*/
static void
symbol_translation (symbol *sym)
symbol_translation (const symbol *sym)
{
/* Nonterminal? */
if (sym->content->class == token_sym
&& !sym->is_alias)
if (sym->content->class == token_sym && !sym->is_alias)
{
/* A token which translation has already been set?*/
/* A token whose translation has already been set? */
if (token_translations[sym->content->code]
!= undeftoken->content->number)
complain_code_redeclared
@@ -969,7 +967,6 @@ dummy_symbol_get (location loc)
assure (len < sizeof buf);
symbol *sym = symbol_get (buf, loc);
sym->content->class = nterm_sym;
sym->content->number = nnterms++;
return sym;
}
@@ -1002,7 +999,7 @@ symbol_cmp (void const *a, void const *b)
}
/* Store in *SORTED an array of pointers to the symbols contained in
TABLE, sorted (alphabetically) by tag. */
TABLE, sorted by order of appearance (i.e., by location). */
static void
table_sort (struct hash_table *table, symbol ***sorted)
+1 -1
View File
@@ -227,7 +227,7 @@ void symbol_precedence_set (symbol *sym, int prec, assoc a, location loc);
void symbol_class_set (symbol *sym, symbol_class class, location loc,
bool declaring);
/** Set the \c code associated with \c sym. */
/** Set the token \c code of \c sym, specified by the user at \c loc. */
void symbol_code_set (symbol *sym, int code, location loc);
+6
View File
@@ -915,6 +915,12 @@ AT_BISON_OPTION_PUSHDEFS([$1])
AT_DATA_CALC_Y([$1])
AT_FULL_COMPILE(AT_JAVA_IF([[Calc]], [[calc]]), AT_DEFINES_IF([[lex], [main]], [[], []]), [$2], [-Wno-deprecated])
AT_YACC_IF(
[# No direct calls to malloc/free.
AT_CHECK([[$EGREP '(malloc|free) *\(' calc.[ch] | $EGREP -v 'INFRINGES ON USER NAME SPACE']],
[1])])
AT_PUSH_IF([AT_JAVA_IF(
[# Verify that this is a push parser.
AT_CHECK_JAVA_GREP([[Calc.java]],
+124 -5
View File
@@ -135,6 +135,10 @@ input.y:9.1-10.0: error: missing '%}' at end of file
AT_CLEANUP
## ------------------------ ##
## Invalid inputs with {}. ##
## ------------------------ ##
AT_SETUP([Invalid inputs with {}])
# We used to SEGV here. See
@@ -816,6 +820,33 @@ input.y:3.8-10: note: previous declaration
AT_CLEANUP
## ---------------- ##
## EOF redeclared. ##
## ---------------- ##
AT_SETUP([EOF redeclared])
# We used to crash when redefining a token after having defined EOF.
# See https://lists.gnu.org/r/bug-bison/2020-08/msg00008.html.
AT_DATA([[input.y]],
[[%token FOO BAR FOO 0
%%
input: %empty
]])
AT_BISON_CHECK([-fcaret input.y], [0], [],
[[input.y:1.16-18: warning: symbol FOO redeclared [-Wother]
1 | %token FOO BAR FOO 0
| ^~~
input.y:1.8-10: note: previous declaration
1 | %token FOO BAR FOO 0
| ^~~
]])
AT_CLEANUP
## --------------------------- ##
## Symbol class redefinition. ##
## --------------------------- ##
@@ -1364,11 +1395,6 @@ AT_CLEANUP
AT_SETUP([Torturing the Scanner])
AT_BISON_OPTION_PUSHDEFS
AT_DATA([input.y], [])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:1.1: error: unexpected end of file
]])
AT_DATA([input.y],
[{}
@@ -2475,6 +2501,99 @@ input.y:5.19: error: invalid character after \-escape: \001
AT_CLEANUP
## ------------------------ ##
## Unexpected end of file. ##
## ------------------------ ##
AT_SETUP([[Unexpected end of file]])
AT_DATA([input.y], [])
AT_BISON_CHECK([-fcaret input.y], [1], [],
[[input.y:1.1: error: unexpected end of file
]])
AT_DATA_NO_FINAL_EOL([char.y],
[[%token FOO ']])
AT_BISON_CHECK([-fcaret char.y], [1], [],
[[char.y:1.12: error: missing "'" at end of file
1 | %token FOO '
| ^
char.y:1.12: error: empty character literal
1 | %token FOO '
| ^
]])
AT_DATA_NO_FINAL_EOL([escape-in-char.y],
[[%token FOO '\]])
AT_BISON_CHECK([-fcaret escape-in-char.y], [1], [],
[[escape-in-char.y:1.12-13: error: missing '?\'' at end of file
1 | %token FOO '\
| ^~
escape-in-char.y:1.14: error: unexpected end of file
1 | %token FOO '\
| ^
]])
AT_DATA_NO_FINAL_EOL([string.y],
[[%token FOO "]])
AT_BISON_CHECK([-fcaret string.y], [1], [],
[[string.y:1.12: error: missing '"' at end of file
1 | %token FOO "
| ^
string.y:1.13: error: unexpected end of file
1 | %token FOO "
| ^
]])
AT_DATA_NO_FINAL_EOL([escape-in-string.y],
[[%token FOO "\]])
AT_BISON_CHECK([-fcaret escape-in-string.y], [1], [],
[[escape-in-string.y:1.12-13: error: missing '?"' at end of file
1 | %token FOO "\
| ^~
escape-in-string.y:1.14: error: unexpected end of file
1 | %token FOO "\
| ^
]])
AT_DATA_NO_FINAL_EOL([tstring.y],
[[%token FOO _("]])
AT_BISON_CHECK([-fcaret tstring.y], [1], [],
[[tstring.y:1.12-14: error: missing '")' at end of file
1 | %token FOO _("
| ^~~
tstring.y:1.15: error: unexpected end of file
1 | %token FOO _("
| ^
]])
AT_DATA_NO_FINAL_EOL([escape-in-tstring.y],
[[%token FOO _("\]])
AT_BISON_CHECK([-fcaret escape-in-tstring.y], [1], [],
[[escape-in-tstring.y:1.12-15: error: missing '?")' at end of file
1 | %token FOO _("\
| ^~~~
escape-in-tstring.y:1.16: error: unexpected end of file
1 | %token FOO _("\
| ^
]])
AT_CLEANUP
## ------------------------- ##
## LAC: Errors for %define. ##
## ------------------------- ##
+1
View File
@@ -390,6 +390,7 @@ AT_LOCATION_TYPE_SPAN_IF(
AT_GLR_IF([AT_KEYWORDS([glr])])
AT_PUSH_IF([AT_KEYWORDS([push])])
])# _AT_BISON_OPTION_PUSHDEFS
+2 -2
View File
@@ -759,7 +759,7 @@ AT_TEST([x1],
])
# Check the CPP guard and Doxyen comments.
AT_CHECK([sed -ne 's/#line [0-9]\+ "/#line "/p;/INCLUDED/p;/\\file/{p;n;p;}' out/include/ast/loc.hh], [],
AT_CHECK([[sed -ne 's/#line [0-9][0-9]* "/#line "/p;/INCLUDED/p;/\\file/{p;n;p;}' out/include/ast/loc.hh]], [],
[[ ** \file bar/include/ast/loc.hh
** Define the x1::location class.
#ifndef YY_YY_BAR_INCLUDE_AST_LOC_HH_INCLUDED
@@ -771,7 +771,7 @@ AT_CHECK([sed -ne 's/#line [0-9]\+ "/#line "/p;/INCLUDED/p;/\\file/{p;n;p;}' out
#endif // !YY_YY_BAR_INCLUDE_AST_LOC_HH_INCLUDED
]])
AT_CHECK([sed -ne 's/^#line [0-9]\+ "/#line "/p;/INCLUDED/p;/\\file/{p;n;p;}' out/x1.hh], [],
AT_CHECK([[sed -ne 's/^#line [0-9][0-9]* "/#line "/p;/INCLUDED/p;/\\file/{p;n;p;}' out/x1.hh]], [],
[[ ** \file bar/x1.hh
** Define the x1::parser class.
#ifndef YY_YY_BAR_X1_HH_INCLUDED