mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-12 12:15:14 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f49684a577 | ||
|
|
044ad1288c | ||
|
|
e3812bb8c3 | ||
|
|
cfcd823e16 | ||
|
|
2f02d9beae | ||
|
|
b638603477 | ||
|
|
e21ff47f5d | ||
|
|
b82b387da9 | ||
|
|
641e326303 | ||
|
|
192e9fdf77 | ||
|
|
a4a3f08c11 | ||
|
|
666df338a7 | ||
|
|
b437b16603 | ||
|
|
b493c173c9 | ||
|
|
aab3feb5a1 | ||
|
|
b7942f2661 | ||
|
|
cefb538ab0 | ||
|
|
26c5f48c1c |
+1
-1
@@ -1 +1 @@
|
||||
3.5.1
|
||||
3.5.2
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
GNU Bison NEWS
|
||||
|
||||
* Noteworthy changes in release 3.5.3 (2020-03-08) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
Error messages could quote lines containing zero-width characters (such as
|
||||
\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.
|
||||
|
||||
* Noteworthy changes in release 3.5.2 (2020-02-13) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
@@ -17,13 +17,18 @@ See the file INSTALL for generic compilation and installation instructions.
|
||||
Bison requires GNU m4 1.4.6 or later. See
|
||||
https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz.
|
||||
|
||||
## Running a non installed bison
|
||||
Once you ran `make`, you might want to toy with this fresh bison before
|
||||
installing it. In that case, do not use `src/bison`: it would use the
|
||||
*installed* files (skeletons, etc.), not the local ones. Use `tests/bison`.
|
||||
|
||||
## Colored diagnostics
|
||||
As an experimental feature, diagnostics are now colored, controlled by the
|
||||
`--color` and `--style` options.
|
||||
|
||||
To use them, install the libtextstyle library before configuring Bison. It
|
||||
is available from https://alpha.gnu.org/gnu/gettext/, for instance
|
||||
https://alpha.gnu.org/gnu/gettext/libtextstyle-0.8.tar.gz.
|
||||
https://alpha.gnu.org/pub/gnu/gettext/libtextstyle-0.20.5.tar.gz.
|
||||
|
||||
The option --color supports the following arguments:
|
||||
- always, yes: Enable colors.
|
||||
@@ -85,18 +90,12 @@ Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU bison, the GNU Compiler Compiler.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
|
||||
Local Variables:
|
||||
mode: markdown
|
||||
|
||||
+16
-1
@@ -34,13 +34,28 @@ Only user visible strings are to be translated: error messages, bits of the
|
||||
assert/abort), and all the --trace output which is meant for the maintainers
|
||||
only.
|
||||
|
||||
## Horizontal tabs
|
||||
## Coding style
|
||||
Follow the GNU Coding Standards.
|
||||
|
||||
Don't reinvent the wheel: we use gnulib, which features many components.
|
||||
Actually, Bison has legacy code that we should replace with gnulib modules
|
||||
(e.g., many adhoc implementations of lists).
|
||||
|
||||
Do not add horizontal tab characters to any file in Bison's repository
|
||||
except where required. For example, do not use tabs to format C code.
|
||||
However, make files, ChangeLog, and some regular expressions require tabs.
|
||||
Also, test cases might need to contain tabs to check that Bison properly
|
||||
processes tabs in its input.
|
||||
|
||||
## Commit messages
|
||||
Please, imitate the style we use. Use `git log` to get sources of
|
||||
inspiration.
|
||||
|
||||
## Debugging
|
||||
Bison supports tracing of its various steps, via the `--trace` option.
|
||||
Since it is not meant for the end user, it is not displayed by `bison
|
||||
--help`, nor is it documented in the manual. Instead, run `bison
|
||||
--trace=help`.
|
||||
|
||||
# Working from the repository
|
||||
|
||||
|
||||
@@ -4,8 +4,9 @@ it is today without the invaluable help of these people:
|
||||
Aaro Koskinen [email protected]
|
||||
Аскар Сафин [email protected]
|
||||
Adam Sampson [email protected]
|
||||
Ahcheong Lee [email protected]
|
||||
Airy Andre [email protected]
|
||||
Akim Demaille akim@lrde.epita.fr
|
||||
Akim Demaille akim@gnu.org
|
||||
Albert Chin-A-Young [email protected]
|
||||
Alexander Belopolsky [email protected]
|
||||
Alexandre Duret-Lutz [email protected]
|
||||
|
||||
@@ -315,13 +315,8 @@ It would be a very nice source of inspiration for the other languages.
|
||||
Valentin Tolmer is working on this.
|
||||
|
||||
** YYERRCODE
|
||||
Defined to 256, but not used, not documented. Probably the token
|
||||
number for the error token, which POSIX wants to be 256, but which
|
||||
Bison might renumber if the user used number 256. Keep fix and doc?
|
||||
Throw away?
|
||||
|
||||
Also, why don't we output the token name of the error token in the
|
||||
output? It is explicitly skipped:
|
||||
Why don't we output the token name of the error token in the output? It is
|
||||
explicitly skipped:
|
||||
|
||||
/* Skip error token and tokens without identifier. */
|
||||
if (sym != errtoken && id)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Written by Akimn Demaille.
|
||||
# Written by Akim Demaille.
|
||||
|
||||
use warnings;
|
||||
use 5.005;
|
||||
|
||||
@@ -1340,7 +1340,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
yyarg[yycount++] = yytname_[yytoken];]b4_lac_if([[
|
||||
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
// Execute LAC once. We don't care if it is succesful, we
|
||||
// Execute LAC once. We don't care if it is successful, we
|
||||
// only do it for the sake of debugging output.
|
||||
if (!yy_lac_established_)
|
||||
yy_lac_check_ (yytoken);
|
||||
|
||||
@@ -673,7 +673,7 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
|
||||
|
||||
/* Error token number */
|
||||
#define YYTERROR 1
|
||||
#define YYERRCODE 256
|
||||
#define YYERRCODE ]b4_symbol(1, user_number)[
|
||||
|
||||
]b4_locations_if([[
|
||||
]b4_yylloc_default_define[
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ Artificial grammar with very long rules.
|
||||
|
||||
=item B<-h>, B<--help>
|
||||
|
||||
Display this message and exit succesfully. The more verbose, the more
|
||||
Display this message and exit successfully. The more verbose, the more
|
||||
details.
|
||||
|
||||
=item B<-i>, B<--iterations>=I<integer>
|
||||
|
||||
@@ -55,5 +55,5 @@ Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
|
||||
# LocalWords: mfcalc calc parsers yy ispell american
|
||||
LocalWords: mfcalc calc parsers yy ispell american
|
||||
--->
|
||||
|
||||
@@ -38,20 +38,12 @@ End:
|
||||
|
||||
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# LocalWords: calc parsers yy MERCHANTABILITY Ctrl ispell american
|
||||
LocalWords: calc parsers yy MERCHANTABILITY Ctrl ispell american
|
||||
--->
|
||||
|
||||
@@ -47,6 +47,8 @@ End:
|
||||
|
||||
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU bison, the GNU Compiler Compiler.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
|
||||
@@ -13,16 +13,11 @@ Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
--->
|
||||
|
||||
@@ -13,16 +13,10 @@ Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
--->
|
||||
|
||||
@@ -28,18 +28,11 @@ End:
|
||||
|
||||
Copyright (C) 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the "GNU Free
|
||||
Documentation License" file as part of this distribution.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
--->
|
||||
|
||||
+1
-1
Submodule gnulib updated: 4fcedca004...d279bc6d9f
+7
-8
@@ -42,9 +42,9 @@
|
||||
|
||||
Internally, we cannot use the number 0 for a rule because for
|
||||
instance RITEM stores both symbol (the RHS) and rule numbers: the
|
||||
symbols are shorts >= 0, and rule number are stored negative.
|
||||
symbols are integers >= 0, and rule numbers are stored negative.
|
||||
Therefore 0 cannot be used, since it would be both the rule number
|
||||
0, and the token $end).
|
||||
0, and the token $end.
|
||||
|
||||
Actions are accessed via the rule number.
|
||||
|
||||
@@ -55,8 +55,7 @@
|
||||
|
||||
RULES[R].lhs -- the symbol of the left hand side of rule R.
|
||||
|
||||
RULES[R].rhs -- the index in RITEM of the beginning of the portion
|
||||
for rule R.
|
||||
RULES[R].rhs -- the beginning of the portion of RITEM for rule R.
|
||||
|
||||
RULES[R].prec -- the symbol providing the precedence level of R.
|
||||
|
||||
@@ -75,16 +74,16 @@
|
||||
|
||||
RULES[R].line -- the line where R was defined.
|
||||
|
||||
RULES[R].useful -- whether the rule is used (i.e., false if thrown
|
||||
away by reduce).
|
||||
RULES[R].useful -- whether the rule is used. False if thrown away
|
||||
by reduce().
|
||||
|
||||
The right hand side is stored as symbol numbers in a portion of
|
||||
RITEM.
|
||||
|
||||
The length of the portion is one greater than the number of symbols
|
||||
in the rule's right hand side. The last element in the portion
|
||||
contains minus R, which identifies it as the end of a portion and
|
||||
says which rule it is for.
|
||||
contains -R, which identifies it as the end of a portion and says
|
||||
which rule it is for.
|
||||
|
||||
The portions of RITEM come in order of increasing rule number.
|
||||
NRITEMS is the total length of RITEM. Each element of RITEM is
|
||||
|
||||
+25
-11
@@ -175,6 +175,8 @@ location_print (location loc, FILE *out)
|
||||
}
|
||||
else
|
||||
{
|
||||
aver (loc.start.file);
|
||||
aver (loc.end.file);
|
||||
int end_col = 0 != loc.end.column ? loc.end.column - 1 : 0;
|
||||
res += fprintf (out, "%s",
|
||||
quotearg_n_style (3, escape_quoting_style, loc.start.file));
|
||||
@@ -317,7 +319,7 @@ caret_getc_internal (mbchar_t *res)
|
||||
|
||||
/* Move CARET_INFO (which has a valid FILE) to the line number LINE.
|
||||
Compute and cache that line's length in CARET_INFO.LINE_LEN.
|
||||
Return whether succesful.*/
|
||||
Return whether successful. */
|
||||
static bool
|
||||
caret_set_line (int line)
|
||||
{
|
||||
@@ -421,12 +423,14 @@ location_caret (location loc, const char *style, FILE *out)
|
||||
{
|
||||
/* The last column to highlight. Only the first line of
|
||||
multiline locations are quoted, in which case the ending
|
||||
column is the end of line. Single point locations (with
|
||||
equal boundaries) denote the character that they
|
||||
follow. */
|
||||
int col_end
|
||||
column is the end of line.
|
||||
|
||||
We used to work with byte offsets, and that was much
|
||||
easier. However, we went back to using (visual) columns to
|
||||
support truncating of long lines. */
|
||||
const int col_end
|
||||
= loc.start.line == loc.end.line
|
||||
? loc.end.column + (loc.start.column == loc.end.column)
|
||||
? loc.end.column
|
||||
: caret_info.line_len;
|
||||
/* Quote the file (at most the first line in the case of
|
||||
multiline locations). */
|
||||
@@ -436,24 +440,28 @@ location_caret (location loc, const char *style, FILE *out)
|
||||
expected (maybe the file was changed since the scanner
|
||||
ran), we might reach the end before we actually saw the
|
||||
opening column. */
|
||||
bool opened = false;
|
||||
enum { before, inside, after } state = before;
|
||||
while (!mb_iseof (c) && !mb_iseq (c, '\n'))
|
||||
{
|
||||
if (caret_info.pos.column == loc.start.column)
|
||||
// We might have already opened (and even closed!) the
|
||||
// style and yet have the equality of the columns if we
|
||||
// just saw zero-width characters.
|
||||
if (state == before
|
||||
&& caret_info.pos.column == loc.start.column)
|
||||
{
|
||||
begin_use_class (style, out);
|
||||
opened = true;
|
||||
state = inside;
|
||||
}
|
||||
if (skip < caret_info.pos.column)
|
||||
mb_putc (c, out);
|
||||
boundary_compute (&caret_info.pos, mb_ptr (c), mb_len (c));
|
||||
caret_getc (c);
|
||||
if (opened
|
||||
if (state == inside
|
||||
&& (caret_info.pos.column == col_end
|
||||
|| width < caret_info.pos.column - skip))
|
||||
{
|
||||
end_use_class (style, out);
|
||||
opened = false;
|
||||
state = after;
|
||||
}
|
||||
if (width < caret_info.pos.column - skip)
|
||||
{
|
||||
@@ -461,6 +469,12 @@ location_caret (location loc, const char *style, FILE *out)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (state == inside)
|
||||
{
|
||||
// The line is shorter than expected.
|
||||
end_use_class (style, out);
|
||||
state = after;
|
||||
}
|
||||
putc ('\n', out);
|
||||
}
|
||||
|
||||
|
||||
+4
-6
@@ -42,16 +42,14 @@ typedef struct
|
||||
|
||||
/* If positive, the column (starting at 1) just after the boundary.
|
||||
This is neither a byte count, nor a character count; it is a
|
||||
column count. If this is INT_MAX, the column number has
|
||||
(visual) column count. If this is INT_MAX, the column number has
|
||||
overflowed.
|
||||
|
||||
Meaningless and not displayed if nonpositive.
|
||||
*/
|
||||
Meaningless and not displayed if nonpositive. */
|
||||
int column;
|
||||
|
||||
/* If nonnegative, the byte number (starting at 0) in the current line.
|
||||
Never displayed, used when printing error messages with colors to
|
||||
know where colors start and end. */
|
||||
/* If nonnegative, the byte number (starting at 0) in the current
|
||||
line. Not displayed (unless --trace=location). */
|
||||
int byte;
|
||||
|
||||
} boundary;
|
||||
|
||||
@@ -58,10 +58,11 @@ core_print (size_t core_size, item_number *core, FILE *out)
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------.
|
||||
| A state was just discovered from another state. Queue it for |
|
||||
| later examination, in order to find its transitions. Return it. |
|
||||
`------------------------------------------------------------------*/
|
||||
/*-----------------------------------------------------------------.
|
||||
| A state was just discovered by transitioning on SYM from another |
|
||||
| state. Queue this state for later examination, in order to find |
|
||||
| its outgoing transitions. Return it. |
|
||||
`-----------------------------------------------------------------*/
|
||||
|
||||
static state *
|
||||
state_list_append (symbol_number sym, size_t core_size, item_number *core)
|
||||
@@ -98,7 +99,7 @@ static state **shiftset;
|
||||
|
||||
|
||||
/* KERNEL_BASE[symbol-number] -> list of item numbers (offsets inside
|
||||
RITEM) of lenngth KERNEL_SIZE[symbol-number]. */
|
||||
RITEM) of length KERNEL_SIZE[symbol-number]. */
|
||||
static item_number **kernel_base;
|
||||
static int *kernel_size;
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
#ifndef LR0_H_
|
||||
# define LR0_H_
|
||||
|
||||
# include "state.h"
|
||||
|
||||
void generate_states (void);
|
||||
|
||||
#endif /* !LR0_H_ */
|
||||
|
||||
@@ -292,7 +292,6 @@ muscle_location_grow (char const *key, location loc)
|
||||
|
||||
#define COMMON_DECODE(Value) \
|
||||
case '$': \
|
||||
++(Value); aver (*(Value) == '['); \
|
||||
++(Value); aver (*(Value) == ']'); \
|
||||
++(Value); aver (*(Value) == '['); \
|
||||
obstack_sgrow (&muscle_obstack, "$"); \
|
||||
|
||||
+1
-1
@@ -610,7 +610,7 @@ packgram (void)
|
||||
{
|
||||
int itemno = 0;
|
||||
ritem = xnmalloc (nritems + 1, sizeof *ritem);
|
||||
/* This sentinel is used by build_relations in gram.c. */
|
||||
/* This sentinel is used by build_relations() in lalr.c. */
|
||||
*ritem++ = 0;
|
||||
|
||||
rule_number ruleno = 0;
|
||||
|
||||
@@ -35,12 +35,6 @@ typedef struct merger_list
|
||||
location type_declaration_loc;
|
||||
} merger_list;
|
||||
|
||||
/* From the parser. */
|
||||
extern int gram_debug;
|
||||
int gram_parse (void);
|
||||
|
||||
|
||||
/* From reader.c. */
|
||||
void grammar_start_symbol_set (symbol *sym, location loc);
|
||||
void grammar_current_rule_begin (symbol *lhs, location loc,
|
||||
named_ref *lhs_named_ref);
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ static bool untyped_var_seen;
|
||||
historically almost any character is allowed in a tag. We disallow
|
||||
NUL and newline, as this simplifies our implementation. We allow
|
||||
"->" as a means to dereference a pointer. */
|
||||
tag ([^\0\n>]|->)+
|
||||
tag ([^\0\n>]|->)*[^-]
|
||||
|
||||
/* Zero or more instances of backslash-newline. Following GCC, allow
|
||||
white space between the backslash and the newline. */
|
||||
|
||||
+6
-1
@@ -77,10 +77,12 @@ sym_content_new (symbol *s)
|
||||
res->symbol = s;
|
||||
|
||||
res->type_name = NULL;
|
||||
res->type_loc = empty_loc;
|
||||
for (int i = 0; i < CODE_PROPS_SIZE; ++i)
|
||||
code_props_none_init (&res->props[i]);
|
||||
|
||||
res->number = NUMBER_UNDEFINED;
|
||||
res->prec_loc = empty_loc;
|
||||
res->prec = 0;
|
||||
res->assoc = undef_assoc;
|
||||
res->user_token_number = USER_NUMBER_UNDEFINED;
|
||||
@@ -553,7 +555,10 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring)
|
||||
_("previous declaration"));
|
||||
}
|
||||
else
|
||||
s->status = declared;
|
||||
{
|
||||
sym->location = loc;
|
||||
s->status = declared;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -225,7 +225,8 @@ void symbol_precedence_set (symbol *sym, int prec, assoc a, location loc);
|
||||
/** Set the \c class associated with \c sym.
|
||||
|
||||
Whether \c declaring means whether this class definition comes
|
||||
from %nterm or %token (but not %type, prec/assoc, etc.). */
|
||||
from %nterm or %token (but not %type, prec/assoc, etc.). A symbol
|
||||
can have "declaring" set only at most once. */
|
||||
void symbol_class_set (symbol *sym, symbol_class class, location loc,
|
||||
bool declaring);
|
||||
|
||||
|
||||
+3
-3
@@ -209,10 +209,10 @@ typedef size_t uintptr_t;
|
||||
|
||||
/* Output Str both quoted for M4 (i.e., embed in [[...]]), and escaped
|
||||
for our postprocessing (i.e., escape M4 special characters). If
|
||||
Str is empty (or NULL), output "[]" instead of "[[]]" as it make M4
|
||||
programming easier (m4_ifval can be used).
|
||||
Str is empty (or NULL), output "[]" instead of "[[]]" as it makes
|
||||
M4 programming easier (m4_ifval can be used).
|
||||
|
||||
For instance "[foo]" -> "[[@{foo@}]]", "$$" -> "[[$][$][]]". */
|
||||
For instance "[foo]" -> "[[@{foo@}]]", "$$" -> "[[$][$][]]". */
|
||||
|
||||
# define obstack_quote(Obs, Str) \
|
||||
do { \
|
||||
|
||||
+64
-5
@@ -37,15 +37,15 @@ AT_BISON_OPTION_PUSHDEFS
|
||||
|
||||
AT_DATA_GRAMMAR([[input.y]], [$2])
|
||||
|
||||
AT_DATA([experr], [$4])
|
||||
|
||||
# For some reason, literal ^M in the input are removed and don't end
|
||||
# in `input.y`. So use the two-character ^M represent it, and let
|
||||
# Perl insert real CR characters.
|
||||
if grep '\^M' input.y >/dev/null; then
|
||||
AT_PERL_REQUIRE([-pi -e 's{\^M}{\r}gx' input.y])
|
||||
if $EGREP ['\^M|\\[0-9][0-9][0-9]'] input.y experr >/dev/null; then
|
||||
AT_PERL_REQUIRE([-pi -e 's{\^M}{\r}g;s{\\(\d{3}|.)}{$v = $[]1; $v =~ /\A\d+\z/ ? chr($v) : $v}ge' input.y experr])
|
||||
fi
|
||||
|
||||
AT_DATA([experr], [$4])
|
||||
|
||||
AT_CHECK([LC_ALL="$locale" $5 bison -fcaret --color=debug -Wall input.y], [$3], [], [experr])
|
||||
|
||||
# When no style, same messages, but without style.
|
||||
@@ -152,6 +152,65 @@ input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option
|
||||
]])
|
||||
|
||||
|
||||
|
||||
## ------------------------------------- ##
|
||||
## Line is too short, and then you die. ##
|
||||
## ------------------------------------- ##
|
||||
|
||||
# We trust the "#line", since that's what allows us to quote the
|
||||
# actual source from which the gramar file was generated. But #line
|
||||
# can also be wrong, and point to a line which is shorter that the bad
|
||||
# one. In which case we can easily forget to close the styling.
|
||||
#
|
||||
# Be sure to have #line point to a line long enough to open the
|
||||
# styling, but not enough to close it.
|
||||
|
||||
AT_TEST([[Line is too short, and then you die]],
|
||||
[[// Beware that there are 9 lines inserted before (including this one).
|
||||
#line 12
|
||||
%token foo 123
|
||||
%token foo 123123
|
||||
%token foo 123
|
||||
%%
|
||||
exp:
|
||||
]],
|
||||
[1],
|
||||
[[input.y:13.8-10: <warning>warning:</warning> symbol foo redeclared [<warning>-Wother</warning>]
|
||||
13 | %token <warning>foo</warning> 123
|
||||
| <warning>^~~</warning>
|
||||
input.y:12.8-10: previous declaration
|
||||
12 | %token <note>foo</note> 123123
|
||||
| <note>^~~</note>
|
||||
input.y:13.12-17: <error>error:</error> redefining user token number of foo
|
||||
13 | %token foo <error>123</error>
|
||||
| <error>^~~~~~</error>
|
||||
input.y:14.8-10: <warning>warning:</warning> symbol foo redeclared [<warning>-Wother</warning>]
|
||||
14 | %%
|
||||
| <warning>^~~</warning>
|
||||
input.y:12.8-10: previous declaration
|
||||
12 | %token <note>foo</note> 123123
|
||||
| <note>^~~</note>
|
||||
]])
|
||||
|
||||
|
||||
## ----------------------- ##
|
||||
## Zero-width characters. ##
|
||||
## ----------------------- ##
|
||||
|
||||
# We used to open twice the styling for characters that have a
|
||||
# zero-width on display (e.g., \005).
|
||||
|
||||
AT_TEST([[Zero-width characters]],
|
||||
[[%%
|
||||
exp: an\005error.
|
||||
]],
|
||||
[1],
|
||||
[[input.y:10.8: <error>error:</error> invalid character: '\\005'
|
||||
10 | exp: an<error>\005</error>error.
|
||||
| <error>^</error>
|
||||
]])
|
||||
|
||||
|
||||
## -------------------------------------- ##
|
||||
## Tabulations and multibyte characters. ##
|
||||
## -------------------------------------- ##
|
||||
@@ -262,7 +321,7 @@ input.y:10.1-27: <error>error:</error> %define variable 'error2' is not used
|
||||
## ----------------- ##
|
||||
|
||||
# Carriage-return used to count as a newline in the scanner, and not
|
||||
# in diagnostics. Resulting in all sort of nice bugs.
|
||||
# in diagnostics. Resulting in all kinds of nice bugs.
|
||||
|
||||
AT_TEST([[Carriage return]],
|
||||
[[^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M
|
||||
|
||||
+69
-1
@@ -298,6 +298,52 @@ input.y:8.14: error: syntax error, unexpected integer
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
## ---------------------------- ##
|
||||
## Redefining the error token. ##
|
||||
## ---------------------------- ##
|
||||
|
||||
AT_SETUP([Redefining the error token])
|
||||
|
||||
# We used to crash when trying to display the original definition of
|
||||
# "error", which is a builtin without any location.
|
||||
|
||||
AT_DATA([input.y],
|
||||
[[%token error 123
|
||||
%token error 124
|
||||
%%
|
||||
exp:
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([-fcaret input.y], [1], [],
|
||||
[[input.y:2.8-12: warning: symbol error redeclared [-Wother]
|
||||
2 | %token error 124
|
||||
| ^~~~~
|
||||
input.y:1.8-12: previous declaration
|
||||
1 | %token error 123
|
||||
| ^~~~~
|
||||
input.y:2.14-16: error: redefining user token number of error
|
||||
2 | %token error 124
|
||||
| ^~~
|
||||
]])
|
||||
|
||||
# While at it, make sure we properly used the user's number for
|
||||
# "error".
|
||||
AT_DATA([input.y],
|
||||
[[%token error 123
|
||||
%%
|
||||
exp:
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([input.y])
|
||||
|
||||
AT_CHECK([$EGREP -E '123|256' input.tab.c], [],
|
||||
[[ 0, 123, 257
|
||||
#define YYERRCODE 123
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
## ------------------ ##
|
||||
## Dangling aliases. ##
|
||||
## ------------------ ##
|
||||
@@ -2069,6 +2115,25 @@ input.y:1.1-34: accepted value: 'consistent'
|
||||
input.y:1.1-34: accepted value: 'accepting'
|
||||
]])
|
||||
|
||||
# Check escapes.
|
||||
AT_DATA([[input.y]],
|
||||
[[%define lr.default-reduction {[$@]}
|
||||
%%
|
||||
start: %empty;
|
||||
]])
|
||||
AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]],
|
||||
[[input.y:1.1-35: warning: %define variable 'lr.default-reduction' requires keyword values [-Wdeprecated]
|
||||
1 | %define lr.default-reduction {[$@]}
|
||||
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
input.y:1.1-35: error: invalid value for %define variable 'lr.default-reduction': '[$@]'
|
||||
1 | %define lr.default-reduction {[$@]}
|
||||
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
input.y:1.1-35: accepted value: 'most'
|
||||
input.y:1.1-35: accepted value: 'consistent'
|
||||
input.y:1.1-35: accepted value: 'accepting'
|
||||
]])
|
||||
|
||||
|
||||
# Back-end.
|
||||
AT_DATA([[input.y]],
|
||||
[[%define api.push-pull neither
|
||||
@@ -2548,7 +2613,9 @@ AT_DATA_GRAMMAR([[input.y]],
|
||||
%printer { $%; @%; } <*> exp TOK;
|
||||
%{ $ @ %} // Should not warn.
|
||||
%%
|
||||
exp: TOK { $%; @%; $$ = $1; };
|
||||
exp: TOK { $%; @%; $$ = $1; }
|
||||
| 'a' { $<->1; $$ = 1; }
|
||||
| 'b' { $<foo->bar>$; }
|
||||
%%
|
||||
$ @ // Should not warn.
|
||||
]])
|
||||
@@ -2562,6 +2629,7 @@ input.y:13.19: warning: stray '$' [-Wother]
|
||||
input.y:13.23: warning: stray '@' [-Wother]
|
||||
input.y:16.19: warning: stray '$' [-Wother]
|
||||
input.y:16.23: warning: stray '@' [-Wother]
|
||||
input.y:17.19: warning: stray '$' [-Wother]
|
||||
]])
|
||||
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
|
||||
Reference in New Issue
Block a user