mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-14 05:05:14 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
108724c2e7 | ||
|
|
da0f993fb9 | ||
|
|
075a879052 | ||
|
|
a7ded4284e | ||
|
|
a5c55bb758 | ||
|
|
bc5aa8e274 | ||
|
|
0a82bf5c07 | ||
|
|
a70e75b8a4 | ||
|
|
3afa9757da | ||
|
|
36f37568ba | ||
|
|
f2c568d3ef | ||
|
|
bb7860d208 |
+1
-1
@@ -1 +1 @@
|
|||||||
3.7.6
|
3.7.90
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ jobs:
|
|||||||
- git fetch --unshallow || true
|
- git fetch --unshallow || true
|
||||||
- git submodule update --init --recursive
|
- git submodule update --init --recursive
|
||||||
|
|
||||||
|
# As of 2021-08, we don't have Autoconf 2.71 on Ubuntu.
|
||||||
|
- sed -i 's/AC_PREREQ(\[2\.71\])/AC_PREREQ([2.69])/g' configure.ac
|
||||||
- ./bootstrap
|
- ./bootstrap
|
||||||
- ./configure --enable-gcc-warnings || { cat config.log && false; }
|
- ./configure --enable-gcc-warnings || { cat config.log && false; }
|
||||||
- make -j2
|
- make -j2
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
GNU Bison NEWS
|
GNU Bison NEWS
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.7.91 (2021-09-02) [beta]
|
||||||
|
|
||||||
|
Portability issues in the test suite and in C++ skeletons.
|
||||||
|
|
||||||
* Noteworthy changes in release 3.7.90 (2021-08-13) [beta]
|
* Noteworthy changes in release 3.7.90 (2021-08-13) [beta]
|
||||||
|
|
||||||
** Backward incompatible changes
|
** Backward incompatible changes
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ simple desk calculators to complex programming languages.
|
|||||||
|
|
||||||
Bison is upward compatible with Yacc: all properly-written Yacc grammars
|
Bison is upward compatible with Yacc: all properly-written Yacc grammars
|
||||||
work with Bison with no change. Anyone familiar with Yacc should be able to
|
work with Bison with no change. Anyone familiar with Yacc should be able to
|
||||||
use Bison with little trouble. You need to be fluent in C, C++ or Java
|
use Bison with little trouble. You need to be fluent in C, C++, D or Java
|
||||||
programming in order to use Bison.
|
programming in order to use Bison.
|
||||||
|
|
||||||
Bison and the parsers it generates are portable, they do not require any
|
Bison and the parsers it generates are portable, they do not require any
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ Les catégories d'avertissements incluent :
|
|||||||
|
|
||||||
Line -1 and -3 should mention CATEGORIE, not CATEGORY.
|
Line -1 and -3 should mention CATEGORIE, not CATEGORY.
|
||||||
|
|
||||||
* Bison 3.8
|
* Bison 3.9
|
||||||
** Rewrite glr.cc (currently glr2.cc)
|
** Rewrite glr.cc (currently glr2.cc)
|
||||||
*** custom error messages
|
*** custom error messages
|
||||||
|
|
||||||
@@ -517,6 +517,9 @@ https://github.com/scfc/bison-php/blob/master/data/lalr1.php
|
|||||||
https://lists.gnu.org/r/bison-patches/2013-09/msg00000.html and following
|
https://lists.gnu.org/r/bison-patches/2013-09/msg00000.html and following
|
||||||
|
|
||||||
** Multiple start symbols
|
** Multiple start symbols
|
||||||
|
Revert a70e75b8a41755ab96ab211a0ea111ac68a4aadd.
|
||||||
|
Revert tests: disable "Multistart reports".
|
||||||
|
|
||||||
Would be very useful when parsing closely related languages. The idea is to
|
Would be very useful when parsing closely related languages. The idea is to
|
||||||
declare several start symbols, for instance
|
declare several start symbols, for instance
|
||||||
|
|
||||||
|
|||||||
@@ -15,11 +15,6 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# In order for some versions of Sun Studio to compile our C++ test cases
|
|
||||||
# correctly, we need Autoconf 2.64 or better to handle the restrict
|
|
||||||
# keyword in at least string.h from gnulib. We need Autoconf 2.68 or
|
|
||||||
# better to avoid a typo in the 'configure --help' entry for the YACC
|
|
||||||
# environment variable.
|
|
||||||
AC_PREREQ([2.71])
|
AC_PREREQ([2.71])
|
||||||
m4_pattern_forbid([^_?(gl_[A-Z]|AX_|BISON_)])
|
m4_pattern_forbid([^_?(gl_[A-Z]|AX_|BISON_)])
|
||||||
m4_pattern_allow([^BISON_USE_NLS$])
|
m4_pattern_allow([^BISON_USE_NLS$])
|
||||||
|
|||||||
@@ -1370,7 +1370,6 @@ public:
|
|||||||
check_ ();
|
check_ ();
|
||||||
other.check_ ();]])[
|
other.check_ ();]])[
|
||||||
std::swap (is_state_, other.is_state_);
|
std::swap (is_state_, other.is_state_);
|
||||||
// NB: swap on arrays is C++11.
|
|
||||||
std::swap (raw_, other.raw_);
|
std::swap (raw_, other.raw_);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -2163,7 +2162,7 @@ b4_dollar_popdef])[]dnl
|
|||||||
reductions on all stacks) helps prevent double destructor calls
|
reductions on all stacks) helps prevent double destructor calls
|
||||||
on yylval in the event of memory exhaustion. */
|
on yylval in the event of memory exhaustion. */
|
||||||
|
|
||||||
for (state_set_index yys = create_state_set_index(0); yys.uget() < this->yystateStack.numTops(); ++yys)
|
for (state_set_index yys = create_state_set_index (0); yys.uget () < this->yystateStack.numTops (); ++yys)
|
||||||
YYCHK1 (this->yyprocessOneStack (yys, yyposn]b4_locations_if([, &this->yylloc])[));
|
YYCHK1 (this->yyprocessOneStack (yys, yyposn]b4_locations_if([, &this->yylloc])[));
|
||||||
this->yystateStack.yytops.yyremoveDeletes ();
|
this->yystateStack.yytops.yyremoveDeletes ();
|
||||||
if (this->yystateStack.yytops.size() == 0)
|
if (this->yystateStack.yytops.size() == 0)
|
||||||
@@ -2173,7 +2172,7 @@ b4_dollar_popdef])[]dnl
|
|||||||
this->yyFail (]b4_locations_if([&this->yylloc, ])[YY_("syntax error"));
|
this->yyFail (]b4_locations_if([&this->yylloc, ])[YY_("syntax error"));
|
||||||
YYCHK1 (this->yyresolveStack ());
|
YYCHK1 (this->yyresolveStack ());
|
||||||
YYCDEBUG << "Returning to deterministic operation.\n";]b4_locations_if([[
|
YYCDEBUG << "Returning to deterministic operation.\n";]b4_locations_if([[
|
||||||
this->yyerror_range[1].getState().yyloc = this->yylloc;]])[
|
this->yyerror_range[1].getState ().yyloc = this->yylloc;]])[
|
||||||
this->yyreportSyntaxError ();
|
this->yyreportSyntaxError ();
|
||||||
goto yyuser_error;
|
goto yyuser_error;
|
||||||
}
|
}
|
||||||
@@ -2186,12 +2185,11 @@ b4_dollar_popdef])[]dnl
|
|||||||
yysymbol_kind_t yytoken_to_shift = this->yytoken;
|
yysymbol_kind_t yytoken_to_shift = this->yytoken;
|
||||||
this->yytoken = ]b4_symbol(empty, kind)[;
|
this->yytoken = ]b4_symbol(empty, kind)[;
|
||||||
yyposn += 1;
|
yyposn += 1;
|
||||||
for (state_set_index yys = create_state_set_index(0); yys.uget() < this->yystateStack.numTops(); ++yys)
|
for (state_set_index yys = create_state_set_index (0); yys.uget () < this->yystateStack.numTops (); ++yys)
|
||||||
{
|
{
|
||||||
const state_num yystate = this->topState(yys)->yylrState;
|
const state_num yystate = this->topState (yys)->yylrState;
|
||||||
const short* yyconflicts;
|
const short* yyconflicts;
|
||||||
const int yyaction
|
const int yyaction = yygetLRActions (yystate, yytoken_to_shift, yyconflicts);
|
||||||
= yygetLRActions (yystate, yytoken_to_shift, yyconflicts);
|
|
||||||
/* Note that yyconflicts were handled by yyprocessOneStack. */
|
/* Note that yyconflicts were handled by yyprocessOneStack. */
|
||||||
YYCDEBUG << "On stack " << yys.get() << ", ";
|
YYCDEBUG << "On stack " << yys.get() << ", ";
|
||||||
YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, this->yylval, this->yylloc);
|
YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, this->yylval, this->yylloc);
|
||||||
@@ -2204,7 +2202,7 @@ b4_dollar_popdef])[]dnl
|
|||||||
// Value type destructor.
|
// Value type destructor.
|
||||||
]b4_symbol_variant([[yytoken_to_shift]], [[this->yylval]], [[template destroy]])])[
|
]b4_symbol_variant([[yytoken_to_shift]], [[this->yylval]], [[template destroy]])])[
|
||||||
|
|
||||||
if (this->yystateStack.yytops.size() == 1)
|
if (this->yystateStack.yytops.size () == 1)
|
||||||
{
|
{
|
||||||
YYCHK1 (this->yyresolveStack ());
|
YYCHK1 (this->yyresolveStack ());
|
||||||
YYCDEBUG << "Returning to deterministic operation.\n";
|
YYCDEBUG << "Returning to deterministic operation.\n";
|
||||||
|
|||||||
@@ -470,21 +470,23 @@ m4_define([_b4_symbol_constructor_define],
|
|||||||
b4_symbol_if([$1], [has_type],
|
b4_symbol_if([$1], [has_type],
|
||||||
[b4_symbol([$1], [type]) v]),
|
[b4_symbol([$1], [type]) v]),
|
||||||
b4_locations_if([location_type l]))[)
|
b4_locations_if([location_type l]))[)
|
||||||
: super_type(]b4_join([token_type (tok)],
|
: super_type (]b4_join([token_type (tok)],
|
||||||
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
||||||
b4_locations_if([std::move (l)]))[)
|
b4_locations_if([std::move (l)]))[)
|
||||||
#else
|
#else
|
||||||
symbol_type (]b4_join(
|
symbol_type (]b4_join(
|
||||||
[int tok],
|
[int tok],
|
||||||
b4_symbol_if([$1], [has_type],
|
b4_symbol_if([$1], [has_type],
|
||||||
[const b4_symbol([$1], [type])& v]),
|
[const b4_symbol([$1], [type])& v]),
|
||||||
b4_locations_if([const location_type& l]))[)
|
b4_locations_if([const location_type& l]))[)
|
||||||
: super_type(]b4_join([token_type (tok)],
|
: super_type (]b4_join([token_type (tok)],
|
||||||
b4_symbol_if([$1], [has_type], [v]),
|
b4_symbol_if([$1], [has_type], [v]),
|
||||||
b4_locations_if([l]))[)
|
b4_locations_if([l]))[)
|
||||||
#endif
|
#endif
|
||||||
{]b4_parse_assert_if([[
|
{]b4_parse_assert_if([[
|
||||||
|
#if !defined _MSC_VER || defined __clang__
|
||||||
]b4_assert[ (]b4_tok_in($@)[);
|
]b4_assert[ (]b4_tok_in($@)[);
|
||||||
|
#endif
|
||||||
]])[}
|
]])[}
|
||||||
]])])
|
]])])
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -1283,17 +1283,17 @@ follows:
|
|||||||
|
|
||||||
@example
|
@example
|
||||||
stmt:
|
stmt:
|
||||||
expr ';' %merge <stmtMerge>
|
expr ';' %merge <stmt_merge>
|
||||||
| decl %merge <stmtMerge>
|
| decl %merge <stmt_merge>
|
||||||
;
|
;
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
and define the @code{stmtMerge} function as:
|
and define the @code{stmt_merge} function as:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
static YYSTYPE
|
static YYSTYPE
|
||||||
stmtMerge (YYSTYPE x0, YYSTYPE x1)
|
stmt_merge (YYSTYPE x0, YYSTYPE x1)
|
||||||
@{
|
@{
|
||||||
printf ("<OR> ");
|
printf ("<OR> ");
|
||||||
return "";
|
return "";
|
||||||
@@ -1306,7 +1306,7 @@ in the C declarations at the beginning of the file:
|
|||||||
|
|
||||||
@example
|
@example
|
||||||
%@{
|
%@{
|
||||||
static YYSTYPE stmtMerge (YYSTYPE x0, YYSTYPE x1);
|
static YYSTYPE stmt_merge (YYSTYPE x0, YYSTYPE x1);
|
||||||
%@}
|
%@}
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@@ -1331,7 +1331,7 @@ previous example, the merged-to symbol (@code{stmt}) does not have a
|
|||||||
specific type, and the merger is
|
specific type, and the merger is
|
||||||
|
|
||||||
@example
|
@example
|
||||||
YYSTYPE stmtMerge (YYSTYPE x0, YYSTYPE x1);
|
YYSTYPE stmt_merge (YYSTYPE x0, YYSTYPE x1);
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
@@ -1358,12 +1358,12 @@ or
|
|||||||
then the prototype of the merger must be:
|
then the prototype of the merger must be:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
Node *stmtMerge (YYSTYPE x0, YYSTYPE x1);
|
Node *stmt_merge (YYSTYPE x0, YYSTYPE x1);
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
(This signature might be a mistake originally, and maybe it should have been
|
(This signature might be a mistake originally, and maybe it should have been
|
||||||
@samp{Node *stmtMerge (Node *x0, Node *x1)}. If you have an opinion about
|
@samp{Node *stmt_merge (Node *x0, Node *x1)}. If you have an opinion about
|
||||||
it, please let us know.)
|
it, please let us know.)
|
||||||
|
|
||||||
@node GLR Semantic Actions
|
@node GLR Semantic Actions
|
||||||
@@ -16594,7 +16594,7 @@ London, Department of Computer Science, TR-00-12 (December 2000).
|
|||||||
@c LocalWords: rpcalc Lexer Expr ltcalc mfcalc yylex defaultprec Donnelly Gotos
|
@c LocalWords: rpcalc Lexer Expr ltcalc mfcalc yylex defaultprec Donnelly Gotos
|
||||||
@c LocalWords: yyerror pxref LR yylval cindex dfn LALR samp gpl BNF xref yypush
|
@c LocalWords: yyerror pxref LR yylval cindex dfn LALR samp gpl BNF xref yypush
|
||||||
@c LocalWords: const int paren ifnotinfo AC noindent emph expr stmt findex lr
|
@c LocalWords: const int paren ifnotinfo AC noindent emph expr stmt findex lr
|
||||||
@c LocalWords: glr YYSTYPE TYPENAME prog dprec printf decl init stmtMerge POSIX
|
@c LocalWords: glr YYSTYPE TYPENAME prog dprec printf decl init POSIX ODR
|
||||||
@c LocalWords: pre STDC GNUC endif yy YY alloca lf stddef stdlib YYDEBUG yypull
|
@c LocalWords: pre STDC GNUC endif yy YY alloca lf stddef stdlib YYDEBUG yypull
|
||||||
@c LocalWords: NUM exp subsubsection kbd Ctrl ctype EOF getchar isdigit nonfree
|
@c LocalWords: NUM exp subsubsection kbd Ctrl ctype EOF getchar isdigit nonfree
|
||||||
@c LocalWords: ungetc stdin scanf sc calc ulator ls lm cc NEG prec yyerrok rr
|
@c LocalWords: ungetc stdin scanf sc calc ulator ls lm cc NEG prec yyerrok rr
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
static Node
|
static Node
|
||||||
stmtMerge (const Node& x0, const Node& x1);
|
stmt_merge (const Node& x0, const Node& x1);
|
||||||
|
|
||||||
static yy::parser::symbol_type
|
static yy::parser::symbol_type
|
||||||
yylex ();
|
yylex ();
|
||||||
@@ -74,9 +74,9 @@ prog : %empty
|
|||||||
| prog stmt { std::cout << @2 << ": " << $2 << '\n'; }
|
| prog stmt { std::cout << @2 << ": " << $2 << '\n'; }
|
||||||
;
|
;
|
||||||
|
|
||||||
stmt : expr ";" %merge <stmtMerge> { $$ = $1; }
|
stmt : expr ";" %merge <stmt_merge> { $$ = $1; }
|
||||||
| decl %merge <stmtMerge>
|
| decl %merge <stmt_merge>
|
||||||
| error ";" { $$ = Nterm ("<error>"); }
|
| error ";" { $$ = Nterm ("<error>"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
expr : ID
|
expr : ID
|
||||||
@@ -169,7 +169,7 @@ yylex ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Node
|
static Node
|
||||||
stmtMerge (const Node& x0, const Node& x1)
|
stmt_merge (const Node& x0, const Node& x1)
|
||||||
{
|
{
|
||||||
return Nterm ("<OR>", x0, x1);
|
return Nterm ("<OR>", x0, x1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
static void free_node (Node *);
|
static void free_node (Node *);
|
||||||
static char *node_to_string (const Node *);
|
static char *node_to_string (const Node *);
|
||||||
static void node_print (FILE *, const Node *);
|
static void node_print (FILE *, const Node *);
|
||||||
static Node *stmtMerge (YYSTYPE x0, YYSTYPE x1);
|
static Node *stmt_merge (YYSTYPE x0, YYSTYPE x1);
|
||||||
|
|
||||||
static void yyerror (YYLTYPE const * const loc, const char *msg);
|
static void yyerror (YYLTYPE const * const loc, const char *msg);
|
||||||
static yytoken_kind_t yylex (YYSTYPE *lval, YYLTYPE *lloc);
|
static yytoken_kind_t yylex (YYSTYPE *lval, YYLTYPE *lloc);
|
||||||
@@ -83,9 +83,9 @@
|
|||||||
|
|
||||||
%glr-parser
|
%glr-parser
|
||||||
|
|
||||||
%type <Node*> stmt expr decl declarator TYPENAME ID
|
%type <Node *> stmt expr decl declarator TYPENAME ID
|
||||||
%destructor { free_node ($$); } <Node*>
|
%destructor { free_node ($$); } <Node *>
|
||||||
%printer { node_print (yyo, $$); } <Node*>
|
%printer { node_print (yyo, $$); } <Node *>
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
@@ -100,8 +100,8 @@ prog : %empty
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
stmt : expr ';' %merge <stmtMerge> { $$ = $1; }
|
stmt : expr ';' %merge <stmt_merge> { $$ = $1; }
|
||||||
| decl %merge <stmtMerge>
|
| decl %merge <stmt_merge>
|
||||||
| error ';' { $$ = new_nterm ("<error>", NULL, NULL, NULL); }
|
| error ';' { $$ = new_nterm ("<error>", NULL, NULL, NULL); }
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -290,8 +290,8 @@ node_print (FILE *out, const Node *n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Node*
|
static Node *
|
||||||
stmtMerge (YYSTYPE x0, YYSTYPE x1)
|
stmt_merge (YYSTYPE x0, YYSTYPE x1)
|
||||||
{
|
{
|
||||||
return new_nterm ("<OR>(%s, %s)", x0.stmt, x1.stmt, NULL);
|
return new_nterm ("<OR>(%s, %s)", x0.stmt, x1.stmt, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,26 +38,9 @@ run -noerr 0 9 -p
|
|||||||
cat >input <<EOF
|
cat >input <<EOF
|
||||||
(1+2) *
|
(1+2) *
|
||||||
EOF
|
EOF
|
||||||
run 1 'err: 1.8-2.0: syntax error, unexpected end of line, expecting ( or number
|
run 1 'err: 1.8-2.0: syntax error, unexpected end of line, expecting ( or number'
|
||||||
err: errors: 1'
|
|
||||||
|
|
||||||
cat >input <<EOF
|
cat >input <<EOF
|
||||||
1 / (2 - 2)
|
1 / (2 - 2)
|
||||||
EOF
|
EOF
|
||||||
run 1 'err: 1.1-11: error: division by zero
|
run 1 'err: 1.1-11: error: division by zero'
|
||||||
err: errors: 1'
|
|
||||||
|
|
||||||
|
|
||||||
# Multistart: parse "expression" instead of "input".
|
|
||||||
cat >input <<EOF
|
|
||||||
1+2*3
|
|
||||||
EOF
|
|
||||||
run 0 'expression: 7' -e
|
|
||||||
|
|
||||||
cat >input <<EOF
|
|
||||||
1
|
|
||||||
2
|
|
||||||
EOF
|
|
||||||
run 1 'expression: failure
|
|
||||||
err: 2.1: syntax error, unexpected number, expecting end of file
|
|
||||||
err: errors: 1' -e
|
|
||||||
|
|||||||
+14
-34
@@ -25,10 +25,10 @@
|
|||||||
{
|
{
|
||||||
// Tell Flex the expected prototype of yylex.
|
// Tell Flex the expected prototype of yylex.
|
||||||
#define YY_DECL \
|
#define YY_DECL \
|
||||||
yytoken_kind_t yylex (YYSTYPE* yylval, YYLTYPE *yylloc)
|
yytoken_kind_t yylex (YYSTYPE* yylval, YYLTYPE *yylloc, int *nerrs)
|
||||||
YY_DECL;
|
YY_DECL;
|
||||||
|
|
||||||
void yyerror (const YYLTYPE *loc, const char *msg);
|
void yyerror (const YYLTYPE *loc, int *nerrs, const char *msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emitted on top of the implementation file.
|
// Emitted on top of the implementation file.
|
||||||
@@ -62,6 +62,9 @@
|
|||||||
// Enable debug traces (see yydebug in main).
|
// Enable debug traces (see yydebug in main).
|
||||||
%define parse.trace
|
%define parse.trace
|
||||||
|
|
||||||
|
// Error count, exchanged between main, yyparse and yylex.
|
||||||
|
%param {int *nerrs}
|
||||||
|
|
||||||
%token
|
%token
|
||||||
PLUS "+"
|
PLUS "+"
|
||||||
MINUS "-"
|
MINUS "-"
|
||||||
@@ -73,11 +76,9 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
%token <int> NUM "number"
|
%token <int> NUM "number"
|
||||||
%type <int> exp expression line
|
%type <int> exp
|
||||||
%printer { fprintf (yyo, "%d", $$); } <int>
|
%printer { fprintf (yyo, "%d", $$); } <int>
|
||||||
|
|
||||||
%start input expression NUM
|
|
||||||
|
|
||||||
// Precedence (from lowest to highest) and associativity.
|
// Precedence (from lowest to highest) and associativity.
|
||||||
%left "+" "-"
|
%left "+" "-"
|
||||||
%left "*" "/"
|
%left "*" "/"
|
||||||
@@ -90,12 +91,8 @@ input:
|
|||||||
;
|
;
|
||||||
|
|
||||||
line:
|
line:
|
||||||
exp EOL { $$ = $exp; printf ("%d\n", $$); }
|
exp EOL { printf ("%d\n", $exp); }
|
||||||
| error EOL { $$ = 0; yyerrok; }
|
| error EOL { yyerrok; }
|
||||||
;
|
|
||||||
|
|
||||||
expression:
|
|
||||||
exp EOL { $$ = $exp; }
|
|
||||||
;
|
;
|
||||||
|
|
||||||
exp:
|
exp:
|
||||||
@@ -106,7 +103,7 @@ exp:
|
|||||||
{
|
{
|
||||||
if ($3 == 0)
|
if ($3 == 0)
|
||||||
{
|
{
|
||||||
yyerror (&@$, "error: division by zero");
|
yyerror (&@$, nerrs, "error: division by zero");
|
||||||
YYERROR;
|
YYERROR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -118,41 +115,24 @@ exp:
|
|||||||
%%
|
%%
|
||||||
// Epilogue (C code).
|
// Epilogue (C code).
|
||||||
|
|
||||||
void yyerror (const YYLTYPE *loc, const char *msg)
|
void yyerror (const YYLTYPE *loc, int *nerrs, const char *msg)
|
||||||
{
|
{
|
||||||
YYLOCATION_PRINT (stderr, loc);
|
YYLOCATION_PRINT (stderr, loc);
|
||||||
fprintf (stderr, ": %s\n", msg);
|
fprintf (stderr, ": %s\n", msg);
|
||||||
|
++*nerrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, const char *argv[])
|
int main (int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
// Possibly enable parser runtime debugging.
|
// Possibly enable parser runtime debugging.
|
||||||
yydebug = !!getenv ("YYDEBUG");
|
yydebug = !!getenv ("YYDEBUG");
|
||||||
int parse_expression_p = 0;
|
|
||||||
int nerrs = 0;
|
|
||||||
|
|
||||||
// Enable parse traces on option -p.
|
// Enable parse traces on option -p.
|
||||||
for (int i = 1; i < argc; ++i)
|
for (int i = 1; i < argc; ++i)
|
||||||
if (strcmp (argv[i], "-e") == 0)
|
if (strcmp (argv[i], "-p") == 0)
|
||||||
parse_expression_p = 1;
|
|
||||||
else if (strcmp (argv[i], "-p") == 0)
|
|
||||||
yydebug = 1;
|
yydebug = 1;
|
||||||
|
|
||||||
if (parse_expression_p)
|
int nerrs = 0;
|
||||||
{
|
yyparse (&nerrs);
|
||||||
yyparse_expression_t res = yyparse_expression ();
|
|
||||||
nerrs = res.yynerrs;
|
|
||||||
if (res.yystatus == 0)
|
|
||||||
printf ("expression: %d\n", res.yyvalue);
|
|
||||||
else
|
|
||||||
printf ("expression: failure\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
nerrs = yyparse_input ().yynerrs;
|
|
||||||
|
|
||||||
if (nerrs)
|
|
||||||
fprintf (stderr, "errors: %d\n", nerrs);
|
|
||||||
|
|
||||||
// Exit on failure if there were errors.
|
// Exit on failure if there were errors.
|
||||||
return !!nerrs;
|
return !!nerrs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
long n = strtol (yytext, NULL, 10);
|
long n = strtol (yytext, NULL, 10);
|
||||||
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
|
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
|
||||||
yyerror (yylloc, "integer is out of range");
|
yyerror (yylloc, nerrs, "integer is out of range");
|
||||||
yylval->TOK_NUM = (int) n;
|
yylval->TOK_NUM = (int) n;
|
||||||
return TOK_NUM;
|
return TOK_NUM;
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
/* Ignore white spaces. */
|
/* Ignore white spaces. */
|
||||||
[ \t]+ LOCATION_STEP (); continue;
|
[ \t]+ LOCATION_STEP (); continue;
|
||||||
|
|
||||||
. yyerror (yylloc, "syntax error, invalid character"); continue;
|
. yyerror (yylloc, nerrs, "syntax error, invalid character"); continue;
|
||||||
|
|
||||||
<<EOF>> return TOK_YYEOF;
|
<<EOF>> return TOK_YYEOF;
|
||||||
%%
|
%%
|
||||||
|
|||||||
+24
-22
@@ -7,36 +7,22 @@
|
|||||||
# with or without modifications, as long as this notice is preserved.
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
m4_define([_BISON_CXXSTD_98_snippet],
|
m4_define([_BISON_CXXSTD_98_snippet],
|
||||||
[[#include <cassert>
|
[[]])
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
void cxx98_vector ()
|
|
||||||
{
|
|
||||||
typedef std::vector<int> ints;
|
|
||||||
|
|
||||||
// Check support for std::vector<T,Allocator>::data.
|
|
||||||
// GCC 4.2 on macOS claims to support C++98, but does not feature it.
|
|
||||||
//
|
|
||||||
// input.cc: In member function 'void state_stack::yycompressStack()':
|
|
||||||
// input.cc:1774: error: 'class std::vector<glr_stack_item, std::allocator<glr_stack_item> >' has no member named 'data'
|
|
||||||
//
|
|
||||||
// <https://trac.macports.org/raw-attachment/ticket/59927/bison-test-results-20210811-95b72.log.xz>.
|
|
||||||
ints my_ints;
|
|
||||||
assert (my_ints.data () == &my_ints[0]);
|
|
||||||
}
|
|
||||||
]])
|
|
||||||
|
|
||||||
m4_define([_BISON_CXXSTD_03_snippet],
|
m4_define([_BISON_CXXSTD_03_snippet],
|
||||||
[])
|
[[]])
|
||||||
|
|
||||||
m4_define([_BISON_CXXSTD_11_snippet],
|
m4_define([_BISON_CXXSTD_11_snippet],
|
||||||
[[#include <algorithm>
|
[[ // C++11
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cassert>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility> // std::swap
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
// C++11
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct check
|
struct check
|
||||||
{
|
{
|
||||||
@@ -80,6 +66,22 @@ m4_define([_BISON_CXXSTD_11_snippet],
|
|||||||
|
|
||||||
// GCC 4.8.2 on Solaris 11.3 does not support to_string.
|
// GCC 4.8.2 on Solaris 11.3 does not support to_string.
|
||||||
auto e = std::to_string(42);
|
auto e = std::to_string(42);
|
||||||
|
|
||||||
|
// Needed by glr2.cc.
|
||||||
|
void cxx11_vector_data ()
|
||||||
|
{
|
||||||
|
std::vector<int> ints;
|
||||||
|
ints.emplace_back (42);
|
||||||
|
assert (ints.data () == &ints[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Needed by glr2.cc.
|
||||||
|
void cxx11_array_swap ()
|
||||||
|
{
|
||||||
|
int i0[4] = { 1, 2, 3, 4 };
|
||||||
|
int i1[4] = { 5, 6, 7, 8 };
|
||||||
|
std::swap (i0, i1);
|
||||||
|
}
|
||||||
]])
|
]])
|
||||||
|
|
||||||
m4_define([_BISON_CXXSTD_14_snippet],
|
m4_define([_BISON_CXXSTD_14_snippet],
|
||||||
@@ -177,7 +179,7 @@ m4_define([_BISON_CXXSTD_testbody],
|
|||||||
|
|
||||||
# BISON_CXXSTD(STD)
|
# BISON_CXXSTD(STD)
|
||||||
# -----------------
|
# -----------------
|
||||||
# Check whether the C++ compiler support STD (11, 98, 2b, etc.).
|
# Check whether the C++ compiler supports STD (11, 98, 2b, etc.).
|
||||||
# If it does, AC_SUBST 'CXX<STD>_CXXFLAGS' to the corresponding flags.
|
# If it does, AC_SUBST 'CXX<STD>_CXXFLAGS' to the corresponding flags.
|
||||||
AC_DEFUN([BISON_CXXSTD],
|
AC_DEFUN([BISON_CXXSTD],
|
||||||
[AC_REQUIRE([AC_PROG_CXX])
|
[AC_REQUIRE([AC_PROG_CXX])
|
||||||
|
|||||||
@@ -28,17 +28,13 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_CXX_COMPILER],
|
|||||||
AC_COMPILE_IFELSE(
|
AC_COMPILE_IFELSE(
|
||||||
[AC_LANG_PROGRAM(
|
[AC_LANG_PROGRAM(
|
||||||
[[
|
[[
|
||||||
#include <cassert>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
using namespace std;]],
|
using namespace std;]],
|
||||||
[[std::cerr << "";
|
[[std::cerr << "";
|
||||||
cout << "";
|
cout << "";
|
||||||
std::vector<int> ints;
|
|
||||||
assert(ints.data () == &ints[0]);
|
|
||||||
typedef std::pair<unsigned, int> uipair;
|
typedef std::pair<unsigned, int> uipair;
|
||||||
std::map<unsigned, int> m;
|
std::map<unsigned, int> m;
|
||||||
std::map<unsigned, int>::iterator i;
|
std::map<unsigned, int>::iterator i;
|
||||||
|
|||||||
@@ -63,6 +63,12 @@
|
|||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
char *cp = getenv ("BISON_PROGRAM_NAME");
|
||||||
|
if (cp)
|
||||||
|
argv[0] = cp;
|
||||||
|
}
|
||||||
|
|
||||||
#define DEPENDS_ON_LIBINTL 1
|
#define DEPENDS_ON_LIBINTL 1
|
||||||
set_program_name (argv[0]);
|
set_program_name (argv[0]);
|
||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
|
|||||||
+5
-19
@@ -25,27 +25,13 @@ abs_top_builddir='@abs_top_builddir@'
|
|||||||
BISON_PKGDATADIR=$abs_top_srcdir/data
|
BISON_PKGDATADIR=$abs_top_srcdir/data
|
||||||
export BISON_PKGDATADIR
|
export BISON_PKGDATADIR
|
||||||
|
|
||||||
stderr=tmp-bison.$$
|
|
||||||
|
|
||||||
# If stderr is a tty, force --color=yes to simulate --color=auto
|
|
||||||
# although we save and modify stderr.
|
|
||||||
if test -t 2; then
|
|
||||||
set x --color=yes ${1+"$@"}
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
# We redirect stderr, which breaks the computation of the terminal
|
|
||||||
# screen width. So export COLUMNS to Bison, hoping for the shell to
|
|
||||||
# have defined it.
|
|
||||||
: ${COLUMNS=`(tput cols) 2>/dev/null || echo 132`}
|
|
||||||
export COLUMNS
|
|
||||||
$PREBISON "$abs_top_builddir/src/bison" ${1+"$@"} 2>"$stderr"
|
|
||||||
status=$?
|
|
||||||
|
|
||||||
# Neutralize path differences in error messages so that check and
|
# Neutralize path differences in error messages so that check and
|
||||||
# installcheck behave the same way.
|
# installcheck behave the same way.
|
||||||
sed -e "s,$abs_top_builddir/src/,,g" <"$stderr" >&2
|
BISON_PROGRAM_NAME=bison
|
||||||
rm -f "$stderr"
|
export BISON_PROGRAM_NAME
|
||||||
|
|
||||||
|
$PREBISON "$abs_top_builddir/src/bison" ${1+"$@"}
|
||||||
|
status=$?
|
||||||
|
|
||||||
# As a special dark magic, if we are actually using this wrapper to
|
# As a special dark magic, if we are actually using this wrapper to
|
||||||
# compile Bison's src/parse-gram.y, post-process the synclines to
|
# compile Bison's src/parse-gram.y, post-process the synclines to
|
||||||
|
|||||||
+1
-1
@@ -970,7 +970,7 @@ AT_JAVA_IF(
|
|||||||
[AT_PARSER_CHECK([calc $1 input], 0, [m4_ifvaln(m4_quote($3), [$3])], [stderr])])
|
[AT_PARSER_CHECK([calc $1 input], 0, [m4_ifvaln(m4_quote($3), [$3])], [stderr])])
|
||||||
AT_LANG_MATCH([c\|c++\|java],
|
AT_LANG_MATCH([c\|c++\|java],
|
||||||
[AT_GLR_IF([],
|
[AT_GLR_IF([],
|
||||||
[AT_CHECK([grep -c -v -E 'Return for a new token:|LAC:' stderr],
|
[AT_CHECK([$EGREP -c -v 'Return for a new token:|LAC:' stderr],
|
||||||
[ignore],
|
[ignore],
|
||||||
[m4_n([AT_DEBUG_IF([$4], [0])])])])])
|
[m4_n([AT_DEBUG_IF([$4], [0])])])])])
|
||||||
])
|
])
|
||||||
|
|||||||
+9
-9
@@ -61,8 +61,8 @@ $1
|
|||||||
static Node *new_term (char *);
|
static Node *new_term (char *);
|
||||||
static void free_node (Node *);
|
static void free_node (Node *);
|
||||||
static char *node_to_string (Node *);
|
static char *node_to_string (Node *);
|
||||||
]m4_bmatch([$2], [stmtMerge],
|
]m4_bmatch([$2], [stmt_merge],
|
||||||
[ static YYSTYPE stmtMerge (YYSTYPE x0, YYSTYPE x1);])[
|
[ static YYSTYPE stmt_merge (YYSTYPE x0, YYSTYPE x1);])[
|
||||||
#define YYINITDEPTH 10
|
#define YYINITDEPTH 10
|
||||||
#define YYSTACKEXPANDABLE 1
|
#define YYSTACKEXPANDABLE 1
|
||||||
]AT_YYERROR_DECLARE[
|
]AT_YYERROR_DECLARE[
|
||||||
@@ -291,9 +291,9 @@ node_to_string (Node *node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
]]
|
]]
|
||||||
m4_bmatch([$2], [stmtMerge],
|
m4_bmatch([$2], [stmt_merge],
|
||||||
[[static YYSTYPE
|
[[static YYSTYPE
|
||||||
stmtMerge (YYSTYPE x0, YYSTYPE x1)
|
stmt_merge (YYSTYPE x0, YYSTYPE x1)
|
||||||
{
|
{
|
||||||
return new_nterm ("<OR>(%s,%s)", x0, x1, YY_NULLPTR);
|
return new_nterm ("<OR>(%s,%s)", x0, x1, YY_NULLPTR);
|
||||||
}
|
}
|
||||||
@@ -431,30 +431,30 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([GLR: Merge conflicting parses, impure, no locations])
|
AT_SETUP([GLR: Merge conflicting parses, impure, no locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([],
|
_AT_TEST_GLR_CXXTYPES([],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmt_merge>], [%merge <stmt_merge>])
|
||||||
AT_TEST([_AT_AMBIG_GLR_OUTPUT], [_AT_GLR_STDERR])
|
AT_TEST([_AT_AMBIG_GLR_OUTPUT], [_AT_GLR_STDERR])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Merge conflicting parses, impure, locations])
|
AT_SETUP([GLR: Merge conflicting parses, impure, locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%locations],
|
_AT_TEST_GLR_CXXTYPES([%locations],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmt_merge>], [%merge <stmt_merge>])
|
||||||
AT_TEST([_AT_AMBIG_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
|
AT_TEST([_AT_AMBIG_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Merge conflicting parses, pure, no locations])
|
AT_SETUP([GLR: Merge conflicting parses, pure, no locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%define api.pure],
|
_AT_TEST_GLR_CXXTYPES([%define api.pure],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmt_merge>], [%merge <stmt_merge>])
|
||||||
AT_TEST([_AT_AMBIG_GLR_OUTPUT], [_AT_GLR_STDERR])
|
AT_TEST([_AT_AMBIG_GLR_OUTPUT], [_AT_GLR_STDERR])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
AT_SETUP([GLR: Merge conflicting parses, pure, locations])
|
AT_SETUP([GLR: Merge conflicting parses, pure, locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%define api.pure %locations],
|
_AT_TEST_GLR_CXXTYPES([%define api.pure %locations],
|
||||||
[%merge <stmtMerge>],[%merge <stmtMerge>])
|
[%merge <stmt_merge>],[%merge <stmt_merge>])
|
||||||
AT_TEST([_AT_AMBIG_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
|
AT_TEST([_AT_AMBIG_GLR_OUTPUT_WITH_LOC], [_AT_GLR_STDERR_WITH_LOC])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Verbose messages, resolve ambiguity, impure, no locations])
|
AT_SETUP([GLR: Verbose messages, resolve ambiguity, impure, no locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%define parse.error verbose],
|
_AT_TEST_GLR_CXXTYPES([%define parse.error verbose],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmt_merge>], [%merge <stmt_merge>])
|
||||||
AT_TEST([_AT_AMBIG_GLR_OUTPUT], [_AT_VERBOSE_GLR_STDERR])
|
AT_TEST([_AT_AMBIG_GLR_OUTPUT], [_AT_VERBOSE_GLR_STDERR])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -1362,8 +1362,10 @@ AT_CHECK(m4_join([ ],
|
|||||||
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
|
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
|
||||||
# with trailing ".o" removed, and ".cc" appended.
|
# with trailing ".o" removed, and ".cc" appended.
|
||||||
m4_define([AT_COMPILE_CXX],
|
m4_define([AT_COMPILE_CXX],
|
||||||
[AT_KEYWORDS(c++)
|
[AT_KEYWORDS([c++])
|
||||||
AT_SKIP_IF([[! $BISON_CXX_WORKS]])
|
AT_SKIP_IF([[! $BISON_CXX_WORKS]])
|
||||||
|
m4_ifdef([AT_GLR2_CC_IF],
|
||||||
|
[AT_GLR2_CC_IF([AT_SKIP_IF([[test x"$CXX11_CXXFLAGS" == x]])])])
|
||||||
AT_CHECK(m4_join([ ],
|
AT_CHECK(m4_join([ ],
|
||||||
[$CXX $CXXFLAGS $CPPFLAGS $3],
|
[$CXX $CXXFLAGS $CPPFLAGS $3],
|
||||||
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
|
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
|
||||||
|
|||||||
@@ -744,6 +744,7 @@ m4_popdef([AT_TEST])
|
|||||||
AT_SETUP([C++ Output File Prefix Mapping])
|
AT_SETUP([C++ Output File Prefix Mapping])
|
||||||
|
|
||||||
# AT_TEST([PREFIX], [DIRECTIVES])
|
# AT_TEST([PREFIX], [DIRECTIVES])
|
||||||
|
# -------------------------------
|
||||||
m4_pushdef([AT_TEST],
|
m4_pushdef([AT_TEST],
|
||||||
[AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc" %define api.namespace {$1} $2])
|
[AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc" %define api.namespace {$1} $2])
|
||||||
AT_LOC_PUSHDEF([begin.line], [begin.column], [end.line], [end.column])
|
AT_LOC_PUSHDEF([begin.line], [begin.column], [end.line], [end.column])
|
||||||
|
|||||||
+1598
-1595
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user