mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-13 04:35:14 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c13bb3484c | ||
|
|
4b6d641913 | ||
|
|
bb990d3809 | ||
|
|
1127a75a72 | ||
|
|
fc28638e1c | ||
|
|
911537c30f | ||
|
|
d4fe9e88f3 | ||
|
|
be22823e78 | ||
|
|
235892350f | ||
|
|
c949ada3da | ||
|
|
d4dcde2b75 | ||
|
|
c8e966e272 | ||
|
|
d4728d92c7 | ||
|
|
09a1cd5e58 |
+1
-1
@@ -1 +1 @@
|
|||||||
2.6.5
|
2.6.90
|
||||||
|
|||||||
@@ -1,20 +1,39 @@
|
|||||||
GNU Bison NEWS
|
GNU Bison NEWS
|
||||||
|
|
||||||
* Noteworthy changes in release 2.6.90 (2012-12-07) [beta]
|
* Noteworthy changes in release 2.7 (2012-12-12) [stable]
|
||||||
|
|
||||||
** Bug fixes
|
** Bug fixes
|
||||||
|
|
||||||
Warnings about uninitialized yylloc in yyparse have been fixed.
|
Warnings about uninitialized yylloc in yyparse have been fixed.
|
||||||
|
|
||||||
** %language is no longer an experimental feature.
|
Restored C90 compliance (yet no report was ever made).
|
||||||
|
|
||||||
The introduction of this feature, in 2.4, was four years ago. The --language
|
** Diagnostics are improved
|
||||||
option and the %language directive are no longer experimental.
|
|
||||||
|
|
||||||
** New format for error reports: carets
|
*** Changes in the format of error messages
|
||||||
|
|
||||||
Caret errors have been added to Bison, for example (taken from the
|
This used to be the format of many error reports:
|
||||||
documentation):
|
|
||||||
|
input.y:2.7-12: %type redeclaration for exp
|
||||||
|
input.y:1.7-12: previous declaration
|
||||||
|
|
||||||
|
It is now:
|
||||||
|
|
||||||
|
input.y:2.7-12: error: %type redeclaration for exp
|
||||||
|
input.y:1.7-12: previous declaration
|
||||||
|
|
||||||
|
*** New format for error reports: carets
|
||||||
|
|
||||||
|
Caret errors have been added to Bison:
|
||||||
|
|
||||||
|
input.y:2.7-12: error: %type redeclaration for exp
|
||||||
|
%type <sval> exp
|
||||||
|
^^^^^^
|
||||||
|
input.y:1.7-12: previous declaration
|
||||||
|
%type <ival> exp
|
||||||
|
^^^^^^
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
input.y:3.20-23: error: ambiguous reference: '$exp'
|
input.y:3.20-23: error: ambiguous reference: '$exp'
|
||||||
exp: exp '+' exp { $exp = $1 + $3; };
|
exp: exp '+' exp { $exp = $1 + $3; };
|
||||||
@@ -29,42 +48,23 @@ GNU Bison NEWS
|
|||||||
exp: exp '+' exp { $exp = $1 + $3; };
|
exp: exp '+' exp { $exp = $1 + $3; };
|
||||||
^^^
|
^^^
|
||||||
|
|
||||||
The default behaviour for now is still not to display these unless explictly
|
The default behaviour for now is still not to display these unless
|
||||||
asked with -fall of -fcaret. However, in a later release, it will be made the
|
explictly asked with -fcaret (or -fall). However, in a later release, it
|
||||||
default behavior (but may still be deactivated with -fno-caret).
|
will be made the default behavior (but may still be deactivated with
|
||||||
|
-fno-caret).
|
||||||
|
|
||||||
** New value for %define variable: api.pure full
|
** New value for %define variable: api.pure full
|
||||||
|
|
||||||
The %define variable api.pure requests a pure (reentrant) parser. However,
|
The %define variable api.pure requests a pure (reentrant) parser. However,
|
||||||
for historical reasons, using it in a location-tracking Yacc parser resulted
|
for historical reasons, using it in a location-tracking Yacc parser
|
||||||
in a yyerror function that did not take a location as a parameter. With this
|
resulted in a yyerror function that did not take a location as a
|
||||||
new value, the user may request a better pure parser, where yyerror does take
|
parameter. With this new value, the user may request a better pure parser,
|
||||||
a location as a parameter (in location-tracking parsers).
|
where yyerror does take a location as a parameter (in location-tracking
|
||||||
|
parsers).
|
||||||
|
|
||||||
The use of "%define api.pure true" is deprecated in favor of this new
|
The use of "%define api.pure true" is deprecated in favor of this new
|
||||||
"%define api.pure full".
|
"%define api.pure full".
|
||||||
|
|
||||||
** Changes in the format of error messages
|
|
||||||
|
|
||||||
This used to be the format of many error reports:
|
|
||||||
|
|
||||||
foo.y:5.10-24: result type clash on merge function 'merge': <t3> != <t2>
|
|
||||||
foo.y:4.13-27: previous declaration
|
|
||||||
|
|
||||||
It is now:
|
|
||||||
|
|
||||||
foo.y:5.10-25: result type clash on merge function 'merge': <t3> != <t2>
|
|
||||||
foo.y:4.13-27: previous declaration
|
|
||||||
|
|
||||||
** Exception safety (lalr1.cc)
|
|
||||||
|
|
||||||
The parse function now catches exceptions, uses the %destructors to
|
|
||||||
release memory (the lookahead symbol and the symbols pushed on the stack)
|
|
||||||
before re-throwing the exception.
|
|
||||||
|
|
||||||
This feature is somewhat experimental. User feedback would be
|
|
||||||
appreciated.
|
|
||||||
|
|
||||||
** New %define variable: api.location.type (glr.cc, lalr1.cc, lalr1.java)
|
** New %define variable: api.location.type (glr.cc, lalr1.cc, lalr1.java)
|
||||||
|
|
||||||
The %define variable api.location.type defines the name of the type to use
|
The %define variable api.location.type defines the name of the type to use
|
||||||
@@ -84,6 +84,15 @@ GNU Bison NEWS
|
|||||||
position_type are deprecated in favor of api.location.type and
|
position_type are deprecated in favor of api.location.type and
|
||||||
api.position.type.
|
api.position.type.
|
||||||
|
|
||||||
|
** Exception safety (lalr1.cc)
|
||||||
|
|
||||||
|
The parse function now catches exceptions, uses the %destructors to
|
||||||
|
release memory (the lookahead symbol and the symbols pushed on the stack)
|
||||||
|
before re-throwing the exception.
|
||||||
|
|
||||||
|
This feature is somewhat experimental. User feedback would be
|
||||||
|
appreciated.
|
||||||
|
|
||||||
** Graph improvements in DOT and XSLT
|
** Graph improvements in DOT and XSLT
|
||||||
|
|
||||||
The graphical presentation of the states is more readable: their shape is
|
The graphical presentation of the states is more readable: their shape is
|
||||||
@@ -96,13 +105,21 @@ GNU Bison NEWS
|
|||||||
These changes are present in both --graph output and xml2dot.xsl XSLT
|
These changes are present in both --graph output and xml2dot.xsl XSLT
|
||||||
processing, with minor (documented) differences.
|
processing, with minor (documented) differences.
|
||||||
|
|
||||||
Two nodes were added to the documentation: Xml and Graphviz.
|
** %language is no longer an experimental feature.
|
||||||
|
|
||||||
|
The introduction of this feature, in 2.4, was four years ago. The
|
||||||
|
--language option and the %language directive are no longer experimental.
|
||||||
|
|
||||||
** Documentation
|
** Documentation
|
||||||
|
|
||||||
The sections about shift/reduce and reduce/reduce conflicts resolution
|
The sections about shift/reduce and reduce/reduce conflicts resolution
|
||||||
have been fixed and extended.
|
have been fixed and extended.
|
||||||
|
|
||||||
|
Although introduced more than four years ago, XML and Graphviz reports
|
||||||
|
were not properly documented.
|
||||||
|
|
||||||
|
The translation of mid-rule actions is now described.
|
||||||
|
|
||||||
* Noteworthy changes in release 2.6.5 (2012-11-07) [stable]
|
* Noteworthy changes in release 2.6.5 (2012-11-07) [stable]
|
||||||
|
|
||||||
We consider compiler warnings about Bison generated parsers to be bugs.
|
We consider compiler warnings about Bison generated parsers to be bugs.
|
||||||
|
|||||||
+2
-1
@@ -135,8 +135,9 @@ if test "$enable_gcc_warnings" = yes; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
BISON_TEST_FOR_WORKING_C_COMPILER
|
BISON_TEST_FOR_WORKING_C_COMPILER
|
||||||
BISON_TEST_FOR_WORKING_CXX_COMPILER
|
|
||||||
BISON_C_COMPILER_POSIXLY_CORRECT
|
BISON_C_COMPILER_POSIXLY_CORRECT
|
||||||
|
BISON_TEST_FOR_WORKING_CXX_COMPILER
|
||||||
|
BISON_CXX_COMPILER_POSIXLY_CORRECT
|
||||||
|
|
||||||
AC_ARG_ENABLE([yacc],
|
AC_ARG_ENABLE([yacc],
|
||||||
[AC_HELP_STRING([--disable-yacc],
|
[AC_HELP_STRING([--disable-yacc],
|
||||||
|
|||||||
+13
-8
@@ -287,7 +287,7 @@ b4_percent_code_get[]dnl
|
|||||||
# include <setjmp.h>
|
# include <setjmp.h>
|
||||||
# define YYJMP_BUF jmp_buf
|
# define YYJMP_BUF jmp_buf
|
||||||
# define YYSETJMP(Env) setjmp (Env)
|
# define YYSETJMP(Env) setjmp (Env)
|
||||||
// Pacify clang.
|
/* Pacify clang. */
|
||||||
# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
|
# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -2013,10 +2013,10 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
|||||||
#if ! YYERROR_VERBOSE
|
#if ! YYERROR_VERBOSE
|
||||||
yyerror (]b4_lyyerror_args[YY_("syntax error"));
|
yyerror (]b4_lyyerror_args[YY_("syntax error"));
|
||||||
#else
|
#else
|
||||||
|
{
|
||||||
yySymbol yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
|
yySymbol yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
|
||||||
size_t yysize0 = yytnamerr (YY_NULL, yytokenName (yytoken));
|
size_t yysize0 = yytnamerr (YY_NULL, yytokenName (yytoken));
|
||||||
size_t yysize = yysize0;
|
size_t yysize = yysize0;
|
||||||
size_t yysize1;
|
|
||||||
yybool yysize_overflow = yyfalse;
|
yybool yysize_overflow = yyfalse;
|
||||||
char* yymsg = YY_NULL;
|
char* yymsg = YY_NULL;
|
||||||
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
||||||
@@ -2076,9 +2076,11 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
yyarg[yycount++] = yytokenName (yyx);
|
yyarg[yycount++] = yytokenName (yyx);
|
||||||
yysize1 = yysize + yytnamerr (YY_NULL, yytokenName (yyx));
|
{
|
||||||
yysize_overflow |= yysize1 < yysize;
|
size_t yysz = yysize + yytnamerr (YY_NULL, yytokenName (yyx));
|
||||||
yysize = yysize1;
|
yysize_overflow |= yysz < yysize;
|
||||||
|
yysize = yysz;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2098,9 +2100,11 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
|||||||
#undef YYCASE_
|
#undef YYCASE_
|
||||||
}
|
}
|
||||||
|
|
||||||
yysize1 = yysize + strlen (yyformat);
|
{
|
||||||
yysize_overflow |= yysize1 < yysize;
|
size_t yysz = yysize + strlen (yyformat);
|
||||||
yysize = yysize1;
|
yysize_overflow |= yysz < yysize;
|
||||||
|
yysize = yysz;
|
||||||
|
}
|
||||||
|
|
||||||
if (!yysize_overflow)
|
if (!yysize_overflow)
|
||||||
yymsg = (char *) YYMALLOC (yysize);
|
yymsg = (char *) YYMALLOC (yysize);
|
||||||
@@ -2130,6 +2134,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
|||||||
yyerror (]b4_lyyerror_args[YY_("syntax error"));
|
yyerror (]b4_lyyerror_args[YY_("syntax error"));
|
||||||
yyMemoryExhausted (yystackp);
|
yyMemoryExhausted (yystackp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif /* YYERROR_VERBOSE */
|
#endif /* YYERROR_VERBOSE */
|
||||||
yynerrs += 1;
|
yynerrs += 1;
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-10
@@ -1247,7 +1247,6 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
|||||||
{
|
{
|
||||||
YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
|
YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
|
||||||
YYSIZE_T yysize = yysize0;
|
YYSIZE_T yysize = yysize0;
|
||||||
YYSIZE_T yysize1;
|
|
||||||
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
||||||
/* Internationalized format string. */
|
/* Internationalized format string. */
|
||||||
const char *yyformat = YY_NULL;
|
const char *yyformat = YY_NULL;
|
||||||
@@ -1328,11 +1327,13 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
yyarg[yycount++] = yytname[yyx];
|
yyarg[yycount++] = yytname[yyx];
|
||||||
yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
|
{
|
||||||
if (! (yysize <= yysize1
|
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
|
||||||
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM))
|
if (! (yysize <= yysize1
|
||||||
return 2;
|
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM))
|
||||||
yysize = yysize1;
|
return 2;
|
||||||
|
yysize = yysize1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}]b4_lac_if([[
|
}]b4_lac_if([[
|
||||||
# if ]b4_api_PREFIX[DEBUG
|
# if ]b4_api_PREFIX[DEBUG
|
||||||
@@ -1356,10 +1357,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
|||||||
# undef YYCASE_
|
# undef YYCASE_
|
||||||
}
|
}
|
||||||
|
|
||||||
yysize1 = yysize + yystrlen (yyformat);
|
{
|
||||||
if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
|
YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
|
||||||
return 2;
|
if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
|
||||||
yysize = yysize1;
|
return 2;
|
||||||
|
yysize = yysize1;
|
||||||
|
}
|
||||||
|
|
||||||
if (*yymsg_alloc < yysize)
|
if (*yymsg_alloc < yysize)
|
||||||
{
|
{
|
||||||
|
|||||||
+5
-4
@@ -96,13 +96,14 @@ PREPATH = $(top_builddir)/src
|
|||||||
|
|
||||||
nodist_man_MANS = yacc.1
|
nodist_man_MANS = yacc.1
|
||||||
|
|
||||||
## ----------------------------- ##
|
## ------------------------------ ##
|
||||||
## Graphviz examples generation. ##
|
## Graphviz examples generation. ##
|
||||||
## ----------------------------- ##
|
## ------------------------------ ##
|
||||||
|
|
||||||
CLEANDIRS += figs
|
CLEANDIRS += figs
|
||||||
FIGS_DOT = figs/example-reduce.dot figs/example-shift.dot
|
FIGS_DOT = figs/example.dot figs/example-reduce.dot figs/example-shift.dot
|
||||||
EXTRA_DIST += \
|
EXTRA_DIST += \
|
||||||
|
figs/example.y \
|
||||||
$(FIGS_DOT) \
|
$(FIGS_DOT) \
|
||||||
$(FIGS_DOT:.dot=.eps) $(FIGS_DOT:.dot=.pdf) $(FIGS_DOT:.dot=.png)
|
$(FIGS_DOT:.dot=.eps) $(FIGS_DOT:.dot=.pdf) $(FIGS_DOT:.dot=.png)
|
||||||
SUFFIXES += .dot .eps .pdf .png
|
SUFFIXES += .dot .eps .pdf .png
|
||||||
|
|||||||
+252
-94
@@ -208,6 +208,12 @@ Defining Language Semantics
|
|||||||
This says when, why and how to use the exceptional
|
This says when, why and how to use the exceptional
|
||||||
action in the middle of a rule.
|
action in the middle of a rule.
|
||||||
|
|
||||||
|
Actions in Mid-Rule
|
||||||
|
|
||||||
|
* Using Mid-Rule Actions:: Putting an action in the middle of a rule.
|
||||||
|
* Mid-Rule Action Translation:: How mid-rule actions are actually processed.
|
||||||
|
* Mid-Rule Conflicts:: Mid-rule actions can cause conflicts.
|
||||||
|
|
||||||
Tracking Locations
|
Tracking Locations
|
||||||
|
|
||||||
* Location Type:: Specifying a data type for locations.
|
* Location Type:: Specifying a data type for locations.
|
||||||
@@ -2722,6 +2728,9 @@ The Bison grammar file conventionally has a name ending in @samp{.y}.
|
|||||||
|
|
||||||
@node Grammar Outline
|
@node Grammar Outline
|
||||||
@section Outline of a Bison Grammar
|
@section Outline of a Bison Grammar
|
||||||
|
@cindex comment
|
||||||
|
@findex // @dots{}
|
||||||
|
@findex /* @dots{} */
|
||||||
|
|
||||||
A Bison grammar file has four main sections, shown here with the
|
A Bison grammar file has four main sections, shown here with the
|
||||||
appropriate delimiters:
|
appropriate delimiters:
|
||||||
@@ -2741,8 +2750,8 @@ appropriate delimiters:
|
|||||||
@end example
|
@end example
|
||||||
|
|
||||||
Comments enclosed in @samp{/* @dots{} */} may appear in any of the sections.
|
Comments enclosed in @samp{/* @dots{} */} may appear in any of the sections.
|
||||||
As a GNU extension, @samp{//} introduces a comment that
|
As a GNU extension, @samp{//} introduces a comment that continues until end
|
||||||
continues until end of line.
|
of line.
|
||||||
|
|
||||||
@menu
|
@menu
|
||||||
* Prologue:: Syntax and usage of the prologue.
|
* Prologue:: Syntax and usage of the prologue.
|
||||||
@@ -3736,6 +3745,15 @@ Occasionally it is useful to put an action in the middle of a rule.
|
|||||||
These actions are written just like usual end-of-rule actions, but they
|
These actions are written just like usual end-of-rule actions, but they
|
||||||
are executed before the parser even recognizes the following components.
|
are executed before the parser even recognizes the following components.
|
||||||
|
|
||||||
|
@menu
|
||||||
|
* Using Mid-Rule Actions:: Putting an action in the middle of a rule.
|
||||||
|
* Mid-Rule Action Translation:: How mid-rule actions are actually processed.
|
||||||
|
* Mid-Rule Conflicts:: Mid-rule actions can cause conflicts.
|
||||||
|
@end menu
|
||||||
|
|
||||||
|
@node Using Mid-Rule Actions
|
||||||
|
@subsubsection Using Mid-Rule Actions
|
||||||
|
|
||||||
A mid-rule action may refer to the components preceding it using
|
A mid-rule action may refer to the components preceding it using
|
||||||
@code{$@var{n}}, but it may not refer to subsequent components because
|
@code{$@var{n}}, but it may not refer to subsequent components because
|
||||||
it is run before they are parsed.
|
it is run before they are parsed.
|
||||||
@@ -3768,10 +3786,16 @@ remove it afterward. Here is how it is done:
|
|||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
stmt:
|
stmt:
|
||||||
LET '(' var ')'
|
"let" '(' var ')'
|
||||||
@{ $<context>$ = push_context (); declare_variable ($3); @}
|
@{
|
||||||
|
$<context>$ = push_context ();
|
||||||
|
declare_variable ($3);
|
||||||
|
@}
|
||||||
stmt
|
stmt
|
||||||
@{ $$ = $6; pop_context ($<context>5); @}
|
@{
|
||||||
|
$$ = $6;
|
||||||
|
pop_context ($<context>5);
|
||||||
|
@}
|
||||||
@end group
|
@end group
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@@ -3782,8 +3806,27 @@ list of accessible variables) as its semantic value, using alternative
|
|||||||
@code{context} in the data-type union. Then it calls
|
@code{context} in the data-type union. Then it calls
|
||||||
@code{declare_variable} to add the new variable to that list. Once the
|
@code{declare_variable} to add the new variable to that list. Once the
|
||||||
first action is finished, the embedded statement @code{stmt} can be
|
first action is finished, the embedded statement @code{stmt} can be
|
||||||
parsed. Note that the mid-rule action is component number 5, so the
|
parsed.
|
||||||
@samp{stmt} is component number 6.
|
|
||||||
|
Note that the mid-rule action is component number 5, so the @samp{stmt} is
|
||||||
|
component number 6. Named references can be used to improve the readability
|
||||||
|
and maintainability (@pxref{Named References}):
|
||||||
|
|
||||||
|
@example
|
||||||
|
@group
|
||||||
|
stmt:
|
||||||
|
"let" '(' var ')'
|
||||||
|
@{
|
||||||
|
$<context>let = push_context ();
|
||||||
|
declare_variable ($3);
|
||||||
|
@}[let]
|
||||||
|
stmt
|
||||||
|
@{
|
||||||
|
$$ = $6;
|
||||||
|
pop_context ($<context>let);
|
||||||
|
@}
|
||||||
|
@end group
|
||||||
|
@end example
|
||||||
|
|
||||||
After the embedded statement is parsed, its semantic value becomes the
|
After the embedded statement is parsed, its semantic value becomes the
|
||||||
value of the entire @code{let}-statement. Then the semantic value from the
|
value of the entire @code{let}-statement. Then the semantic value from the
|
||||||
@@ -3817,13 +3860,13 @@ stmt:
|
|||||||
let stmt
|
let stmt
|
||||||
@{
|
@{
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
pop_context ($1);
|
pop_context ($let);
|
||||||
@};
|
@};
|
||||||
|
|
||||||
let:
|
let:
|
||||||
LET '(' var ')'
|
"let" '(' var ')'
|
||||||
@{
|
@{
|
||||||
$$ = push_context ();
|
$let = push_context ();
|
||||||
declare_variable ($3);
|
declare_variable ($3);
|
||||||
@};
|
@};
|
||||||
|
|
||||||
@@ -3835,6 +3878,76 @@ Note that the action is now at the end of its rule.
|
|||||||
Any mid-rule action can be converted to an end-of-rule action in this way, and
|
Any mid-rule action can be converted to an end-of-rule action in this way, and
|
||||||
this is what Bison actually does to implement mid-rule actions.
|
this is what Bison actually does to implement mid-rule actions.
|
||||||
|
|
||||||
|
@node Mid-Rule Action Translation
|
||||||
|
@subsubsection Mid-Rule Action Translation
|
||||||
|
@vindex $@@@var{n}
|
||||||
|
@vindex @@@var{n}
|
||||||
|
|
||||||
|
As hinted earlier, mid-rule actions are actually transformed into regular
|
||||||
|
rules and actions. The various reports generated by Bison (textual,
|
||||||
|
graphical, etc., see @ref{Understanding, , Understanding Your Parser})
|
||||||
|
reveal this translation, best explained by means of an example. The
|
||||||
|
following rule:
|
||||||
|
|
||||||
|
@example
|
||||||
|
exp: @{ a(); @} "b" @{ c(); @} @{ d(); @} "e" @{ f(); @};
|
||||||
|
@end example
|
||||||
|
|
||||||
|
@noindent
|
||||||
|
is translated into:
|
||||||
|
|
||||||
|
@example
|
||||||
|
$@@1: /* empty */ @{ a(); @};
|
||||||
|
$@@2: /* empty */ @{ c(); @};
|
||||||
|
$@@3: /* empty */ @{ d(); @};
|
||||||
|
exp: $@@1 "b" $@@2 $@@3 "e" @{ f(); @};
|
||||||
|
@end example
|
||||||
|
|
||||||
|
@noindent
|
||||||
|
with new nonterminal symbols @code{$@@@var{n}}, where @var{n} is a number.
|
||||||
|
|
||||||
|
A mid-rule action is expected to generate a value if it uses @code{$$}, or
|
||||||
|
the (final) action uses @code{$@var{n}} where @var{n} denote the mid-rule
|
||||||
|
action. In that case its nonterminal is rather named @code{@@@var{n}}:
|
||||||
|
|
||||||
|
@example
|
||||||
|
exp: @{ a(); @} "b" @{ $$ = c(); @} @{ d(); @} "e" @{ f = $1; @};
|
||||||
|
@end example
|
||||||
|
|
||||||
|
@noindent
|
||||||
|
is translated into
|
||||||
|
|
||||||
|
@example
|
||||||
|
@@1: /* empty */ @{ a(); @};
|
||||||
|
@@2: /* empty */ @{ $$ = c(); @};
|
||||||
|
$@@3: /* empty */ @{ d(); @};
|
||||||
|
exp: @@1 "b" @@2 $@@3 "e" @{ f = $1; @}
|
||||||
|
@end example
|
||||||
|
|
||||||
|
There are probably two errors in the above example: the first mid-rule
|
||||||
|
action does not generate a value (it does not use @code{$$} although the
|
||||||
|
final action uses it), and the value of the second one is not used (the
|
||||||
|
final action does not use @code{$3}). Bison reports these errors when the
|
||||||
|
@code{midrule-value} warnings are enabled (@pxref{Invocation, ,Invoking
|
||||||
|
Bison}):
|
||||||
|
|
||||||
|
@example
|
||||||
|
$ bison -fcaret -Wmidrule-value mid.y
|
||||||
|
@group
|
||||||
|
mid.y:2.6-13: warning: unset value: $$
|
||||||
|
exp: @{ a(); @} "b" @{ $$ = c(); @} @{ d(); @} "e" @{ f = $1; @};
|
||||||
|
^^^^^^^^
|
||||||
|
@end group
|
||||||
|
@group
|
||||||
|
mid.y:2.19-31: warning: unused value: $3
|
||||||
|
exp: @{ a(); @} "b" @{ $$ = c(); @} @{ d(); @} "e" @{ f = $1; @};
|
||||||
|
^^^^^^^^^^^^^
|
||||||
|
@end group
|
||||||
|
@end example
|
||||||
|
|
||||||
|
|
||||||
|
@node Mid-Rule Conflicts
|
||||||
|
@subsubsection Conflicts due to Mid-Rule Actions
|
||||||
Taking action before a rule is completely recognized often leads to
|
Taking action before a rule is completely recognized often leads to
|
||||||
conflicts since the parser must commit to a parse in order to execute the
|
conflicts since the parser must commit to a parse in order to execute the
|
||||||
action. For example, the following two rules, without mid-rule actions,
|
action. For example, the following two rules, without mid-rule actions,
|
||||||
@@ -3932,6 +4045,7 @@ compound:
|
|||||||
Now Bison can execute the action in the rule for @code{subroutine} without
|
Now Bison can execute the action in the rule for @code{subroutine} without
|
||||||
deciding which rule for @code{compound} it will eventually use.
|
deciding which rule for @code{compound} it will eventually use.
|
||||||
|
|
||||||
|
|
||||||
@node Tracking Locations
|
@node Tracking Locations
|
||||||
@section Tracking Locations
|
@section Tracking Locations
|
||||||
@cindex location
|
@cindex location
|
||||||
@@ -5389,8 +5503,8 @@ I.e., if @samp{%locations %define api.pure} is passed then the prototypes for
|
|||||||
@code{yyerror} are:
|
@code{yyerror} are:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
void yyerror (char const *msg); /* Yacc parsers. */
|
void yyerror (char const *msg); // Yacc parsers.
|
||||||
void yyerror (YYLTYPE *locp, char const *msg); /* GLR parsers. */
|
void yyerror (YYLTYPE *locp, char const *msg); // GLR parsers.
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
But if @samp{%locations %define api.pure %parse-param @{int *nastiness@}} is
|
But if @samp{%locations %define api.pure %parse-param @{int *nastiness@}} is
|
||||||
@@ -6386,7 +6500,6 @@ Actions}).
|
|||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Value} @@$
|
@deffn {Value} @@$
|
||||||
@findex @@$
|
|
||||||
Acts like a structure variable containing information on the textual
|
Acts like a structure variable containing information on the textual
|
||||||
location of the grouping made by the current rule. @xref{Tracking
|
location of the grouping made by the current rule. @xref{Tracking
|
||||||
Locations}.
|
Locations}.
|
||||||
@@ -6445,7 +6558,7 @@ GNU Automake.
|
|||||||
@item
|
@item
|
||||||
@cindex bison-i18n.m4
|
@cindex bison-i18n.m4
|
||||||
Into the directory containing the GNU Autoconf macros used
|
Into the directory containing the GNU Autoconf macros used
|
||||||
by the package---often called @file{m4}---copy the
|
by the package ---often called @file{m4}--- copy the
|
||||||
@file{bison-i18n.m4} file installed by Bison under
|
@file{bison-i18n.m4} file installed by Bison under
|
||||||
@samp{share/aclocal/bison-i18n.m4} in Bison's installation directory.
|
@samp{share/aclocal/bison-i18n.m4} in Bison's installation directory.
|
||||||
For example:
|
For example:
|
||||||
@@ -8191,8 +8304,26 @@ clear the flag.
|
|||||||
|
|
||||||
Developing a parser can be a challenge, especially if you don't understand
|
Developing a parser can be a challenge, especially if you don't understand
|
||||||
the algorithm (@pxref{Algorithm, ,The Bison Parser Algorithm}). This
|
the algorithm (@pxref{Algorithm, ,The Bison Parser Algorithm}). This
|
||||||
chapter explains how to generate and read the detailed description of the
|
chapter explains how understand and debug a parser.
|
||||||
automaton, and how to enable and understand the parser run-time traces.
|
|
||||||
|
The first sections focus on the static part of the parser: its structure.
|
||||||
|
They explain how to generate and read the detailed description of the
|
||||||
|
automaton. There are several formats available:
|
||||||
|
@itemize @minus
|
||||||
|
@item
|
||||||
|
as text, see @ref{Understanding, , Understanding Your Parser};
|
||||||
|
|
||||||
|
@item
|
||||||
|
as a graph, see @ref{Graphviz,, Visualizing Your Parser};
|
||||||
|
|
||||||
|
@item
|
||||||
|
or as a markup report that can be turned, for instance, into HTML, see
|
||||||
|
@ref{Xml,, Visualizing your parser in multiple formats}.
|
||||||
|
@end itemize
|
||||||
|
|
||||||
|
The last section focuses on the dynamic part of the parser: how to enable
|
||||||
|
and understand the parser run-time traces (@pxref{Tracing, ,Tracing Your
|
||||||
|
Parser}).
|
||||||
|
|
||||||
@menu
|
@menu
|
||||||
* Understanding:: Understanding the structure of your parser.
|
* Understanding:: Understanding the structure of your parser.
|
||||||
@@ -8207,8 +8338,7 @@ automaton, and how to enable and understand the parser run-time traces.
|
|||||||
As documented elsewhere (@pxref{Algorithm, ,The Bison Parser Algorithm})
|
As documented elsewhere (@pxref{Algorithm, ,The Bison Parser Algorithm})
|
||||||
Bison parsers are @dfn{shift/reduce automata}. In some cases (much more
|
Bison parsers are @dfn{shift/reduce automata}. In some cases (much more
|
||||||
frequent than one would hope), looking at this automaton is required to
|
frequent than one would hope), looking at this automaton is required to
|
||||||
tune or simply fix a parser. Bison provides two different
|
tune or simply fix a parser.
|
||||||
representation of it, either textually or graphically (as a DOT file).
|
|
||||||
|
|
||||||
The textual file is generated when the options @option{--report} or
|
The textual file is generated when the options @option{--report} or
|
||||||
@option{--verbose} are specified, see @ref{Invocation, , Invoking
|
@option{--verbose} are specified, see @ref{Invocation, , Invoking
|
||||||
@@ -8222,9 +8352,12 @@ The following grammar file, @file{calc.y}, will be used in the sequel:
|
|||||||
|
|
||||||
@example
|
@example
|
||||||
%token NUM STR
|
%token NUM STR
|
||||||
|
@group
|
||||||
%left '+' '-'
|
%left '+' '-'
|
||||||
%left '*'
|
%left '*'
|
||||||
|
@end group
|
||||||
%%
|
%%
|
||||||
|
@group
|
||||||
exp:
|
exp:
|
||||||
exp '+' exp
|
exp '+' exp
|
||||||
| exp '-' exp
|
| exp '-' exp
|
||||||
@@ -8232,6 +8365,7 @@ exp:
|
|||||||
| exp '/' exp
|
| exp '/' exp
|
||||||
| NUM
|
| NUM
|
||||||
;
|
;
|
||||||
|
@end group
|
||||||
useless: STR;
|
useless: STR;
|
||||||
%%
|
%%
|
||||||
@end example
|
@end example
|
||||||
@@ -8241,8 +8375,8 @@ useless: STR;
|
|||||||
@example
|
@example
|
||||||
calc.y: warning: 1 nonterminal useless in grammar
|
calc.y: warning: 1 nonterminal useless in grammar
|
||||||
calc.y: warning: 1 rule useless in grammar
|
calc.y: warning: 1 rule useless in grammar
|
||||||
calc.y:11.1-7: warning: nonterminal useless in grammar: useless
|
calc.y:12.1-7: warning: nonterminal useless in grammar: useless
|
||||||
calc.y:11.10-12: warning: rule useless in grammar: useless: STR
|
calc.y:12.10-12: warning: rule useless in grammar: useless: STR
|
||||||
calc.y: conflicts: 7 shift/reduce
|
calc.y: conflicts: 7 shift/reduce
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@@ -8336,7 +8470,7 @@ item is a production rule together with a point (@samp{.}) marking
|
|||||||
the location of the input cursor.
|
the location of the input cursor.
|
||||||
|
|
||||||
@example
|
@example
|
||||||
state 0
|
State 0
|
||||||
|
|
||||||
0 $accept: . exp $end
|
0 $accept: . exp $end
|
||||||
|
|
||||||
@@ -8366,7 +8500,7 @@ you want to see more detail you can invoke @command{bison} with
|
|||||||
@option{--report=itemset} to list the derived items as well:
|
@option{--report=itemset} to list the derived items as well:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
state 0
|
State 0
|
||||||
|
|
||||||
0 $accept: . exp $end
|
0 $accept: . exp $end
|
||||||
1 exp: . exp '+' exp
|
1 exp: . exp '+' exp
|
||||||
@@ -8384,7 +8518,7 @@ state 0
|
|||||||
In the state 1@dots{}
|
In the state 1@dots{}
|
||||||
|
|
||||||
@example
|
@example
|
||||||
state 1
|
State 1
|
||||||
|
|
||||||
5 exp: NUM .
|
5 exp: NUM .
|
||||||
|
|
||||||
@@ -8394,11 +8528,11 @@ state 1
|
|||||||
@noindent
|
@noindent
|
||||||
the rule 5, @samp{exp: NUM;}, is completed. Whatever the lookahead token
|
the rule 5, @samp{exp: NUM;}, is completed. Whatever the lookahead token
|
||||||
(@samp{$default}), the parser will reduce it. If it was coming from
|
(@samp{$default}), the parser will reduce it. If it was coming from
|
||||||
state 0, then, after this reduction it will return to state 0, and will
|
State 0, then, after this reduction it will return to state 0, and will
|
||||||
jump to state 2 (@samp{exp: go to state 2}).
|
jump to state 2 (@samp{exp: go to state 2}).
|
||||||
|
|
||||||
@example
|
@example
|
||||||
state 2
|
State 2
|
||||||
|
|
||||||
0 $accept: exp . $end
|
0 $accept: exp . $end
|
||||||
1 exp: exp . '+' exp
|
1 exp: exp . '+' exp
|
||||||
@@ -8426,7 +8560,7 @@ The state 3 is named the @dfn{final state}, or the @dfn{accepting
|
|||||||
state}:
|
state}:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
state 3
|
State 3
|
||||||
|
|
||||||
0 $accept: exp $end .
|
0 $accept: exp $end .
|
||||||
|
|
||||||
@@ -8441,7 +8575,7 @@ The interpretation of states 4 to 7 is straightforward, and is left to
|
|||||||
the reader.
|
the reader.
|
||||||
|
|
||||||
@example
|
@example
|
||||||
state 4
|
State 4
|
||||||
|
|
||||||
1 exp: exp '+' . exp
|
1 exp: exp '+' . exp
|
||||||
|
|
||||||
@@ -8450,7 +8584,7 @@ state 4
|
|||||||
exp go to state 8
|
exp go to state 8
|
||||||
|
|
||||||
|
|
||||||
state 5
|
State 5
|
||||||
|
|
||||||
2 exp: exp '-' . exp
|
2 exp: exp '-' . exp
|
||||||
|
|
||||||
@@ -8459,7 +8593,7 @@ state 5
|
|||||||
exp go to state 9
|
exp go to state 9
|
||||||
|
|
||||||
|
|
||||||
state 6
|
State 6
|
||||||
|
|
||||||
3 exp: exp '*' . exp
|
3 exp: exp '*' . exp
|
||||||
|
|
||||||
@@ -8468,7 +8602,7 @@ state 6
|
|||||||
exp go to state 10
|
exp go to state 10
|
||||||
|
|
||||||
|
|
||||||
state 7
|
State 7
|
||||||
|
|
||||||
4 exp: exp '/' . exp
|
4 exp: exp '/' . exp
|
||||||
|
|
||||||
@@ -8481,7 +8615,7 @@ As was announced in beginning of the report, @samp{State 8 conflicts:
|
|||||||
1 shift/reduce}:
|
1 shift/reduce}:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
state 8
|
State 8
|
||||||
|
|
||||||
1 exp: exp . '+' exp
|
1 exp: exp . '+' exp
|
||||||
1 | exp '+' exp .
|
1 | exp '+' exp .
|
||||||
@@ -8524,7 +8658,7 @@ with some set of possible lookahead tokens. When run with
|
|||||||
@option{--report=lookahead}, Bison specifies these lookahead tokens:
|
@option{--report=lookahead}, Bison specifies these lookahead tokens:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
state 8
|
State 8
|
||||||
|
|
||||||
1 exp: exp . '+' exp
|
1 exp: exp . '+' exp
|
||||||
1 | exp '+' exp . [$end, '+', '-', '/']
|
1 | exp '+' exp . [$end, '+', '-', '/']
|
||||||
@@ -8556,7 +8690,7 @@ The remaining states are similar:
|
|||||||
|
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
state 9
|
State 9
|
||||||
|
|
||||||
1 exp: exp . '+' exp
|
1 exp: exp . '+' exp
|
||||||
2 | exp . '-' exp
|
2 | exp . '-' exp
|
||||||
@@ -8572,7 +8706,7 @@ state 9
|
|||||||
@end group
|
@end group
|
||||||
|
|
||||||
@group
|
@group
|
||||||
state 10
|
State 10
|
||||||
|
|
||||||
1 exp: exp . '+' exp
|
1 exp: exp . '+' exp
|
||||||
2 | exp . '-' exp
|
2 | exp . '-' exp
|
||||||
@@ -8587,7 +8721,7 @@ state 10
|
|||||||
@end group
|
@end group
|
||||||
|
|
||||||
@group
|
@group
|
||||||
state 11
|
State 11
|
||||||
|
|
||||||
1 exp: exp . '+' exp
|
1 exp: exp . '+' exp
|
||||||
2 | exp . '-' exp
|
2 | exp . '-' exp
|
||||||
@@ -8610,12 +8744,11 @@ state 11
|
|||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
Observe that state 11 contains conflicts not only due to the lack of
|
Observe that state 11 contains conflicts not only due to the lack of
|
||||||
precedence of @samp{/} with respect to @samp{+}, @samp{-}, and
|
precedence of @samp{/} with respect to @samp{+}, @samp{-}, and @samp{*}, but
|
||||||
@samp{*}, but also because the
|
also because the associativity of @samp{/} is not specified.
|
||||||
associativity of @samp{/} is not specified.
|
|
||||||
|
|
||||||
Note that Bison may also produce an HTML version of this output, via an XML
|
Bison may also produce an HTML version of this output, via an XML file and
|
||||||
file and XSLT processing (@pxref{Xml}).
|
XSLT processing (@pxref{Xml,,Visualizing your parser in multiple formats}).
|
||||||
|
|
||||||
@c ================================================= Graphical Representation
|
@c ================================================= Graphical Representation
|
||||||
|
|
||||||
@@ -8635,7 +8768,10 @@ This file is generated when the @option{--graph} option is specified
|
|||||||
(@pxref{Invocation, , Invoking Bison}). Its name is made by removing
|
(@pxref{Invocation, , Invoking Bison}). Its name is made by removing
|
||||||
@samp{.tab.c} or @samp{.c} from the parser implementation file name, and
|
@samp{.tab.c} or @samp{.c} from the parser implementation file name, and
|
||||||
adding @samp{.dot} instead. If the grammar file is @file{foo.y}, the
|
adding @samp{.dot} instead. If the grammar file is @file{foo.y}, the
|
||||||
Graphviz output file is called @file{foo.dot}.
|
Graphviz output file is called @file{foo.dot}. A DOT file may also be
|
||||||
|
produced via an XML file and XSLT processing (@pxref{Xml,,Visualizing your
|
||||||
|
parser in multiple formats}).
|
||||||
|
|
||||||
|
|
||||||
The following grammar file, @file{rr.y}, will be used in the sequel:
|
The following grammar file, @file{rr.y}, will be used in the sequel:
|
||||||
|
|
||||||
@@ -8648,10 +8784,20 @@ b: "0";
|
|||||||
@end group
|
@end group
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
The graphical output is very similar to the textual one, and as such it is
|
The graphical output
|
||||||
easier understood by making direct comparisons between them. See
|
@ifnotinfo
|
||||||
@ref{Debugging, , Debugging Your Parser} for a detailled analysis of the
|
(see @ref{fig:graph})
|
||||||
textual report.
|
@end ifnotinfo
|
||||||
|
is very similar to the textual one, and as such it is easier understood by
|
||||||
|
making direct comparisons between them. @xref{Debugging, , Debugging Your
|
||||||
|
Parser}, for a detailled analysis of the textual report.
|
||||||
|
|
||||||
|
@ifnotinfo
|
||||||
|
@float Figure,fig:graph
|
||||||
|
@image{figs/example, 430pt}
|
||||||
|
@caption{A graphical rendering of the parser.}
|
||||||
|
@end float
|
||||||
|
@end ifnotinfo
|
||||||
|
|
||||||
@subheading Graphical Representation of States
|
@subheading Graphical Representation of States
|
||||||
|
|
||||||
@@ -8676,7 +8822,7 @@ shift. The following describes a reduction in the @file{rr.output} file:
|
|||||||
|
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
state 3
|
State 3
|
||||||
|
|
||||||
1 exp: a . ";"
|
1 exp: a . ";"
|
||||||
|
|
||||||
@@ -8697,7 +8843,7 @@ action for the given state, there is no such label.
|
|||||||
|
|
||||||
This is how reductions are represented in the verbose file @file{rr.output}:
|
This is how reductions are represented in the verbose file @file{rr.output}:
|
||||||
@example
|
@example
|
||||||
state 1
|
State 1
|
||||||
|
|
||||||
3 a: "0" . [";"]
|
3 a: "0" . [";"]
|
||||||
4 b: "0" . ["."]
|
4 b: "0" . ["."]
|
||||||
@@ -8716,17 +8862,14 @@ reduction, see @ref{Shift/Reduce, , Shift/Reduce Conflicts}. Discarded actions
|
|||||||
are distinguished by a red filling color on these nodes, just like how they are
|
are distinguished by a red filling color on these nodes, just like how they are
|
||||||
reported between square brackets in the verbose file.
|
reported between square brackets in the verbose file.
|
||||||
|
|
||||||
The reduction corresponding to the rule number 0 is the acceptation state. It
|
The reduction corresponding to the rule number 0 is the acceptation
|
||||||
is shown as a blue diamond, labelled "Acc".
|
state. It is shown as a blue diamond, labelled ``Acc''.
|
||||||
|
|
||||||
@subheading Graphical representation of go tos
|
@subheading Graphical representation of go tos
|
||||||
|
|
||||||
The @samp{go to} jump transitions are represented as dotted lines bearing
|
The @samp{go to} jump transitions are represented as dotted lines bearing
|
||||||
the name of the rule being jumped to.
|
the name of the rule being jumped to.
|
||||||
|
|
||||||
Note that a DOT file may also be produced via an XML file and XSLT
|
|
||||||
processing (@pxref{Xml}).
|
|
||||||
|
|
||||||
@c ================================================= XML
|
@c ================================================= XML
|
||||||
|
|
||||||
@node Xml
|
@node Xml
|
||||||
@@ -8734,8 +8877,10 @@ processing (@pxref{Xml}).
|
|||||||
@cindex xml
|
@cindex xml
|
||||||
|
|
||||||
Bison supports two major report formats: textual output
|
Bison supports two major report formats: textual output
|
||||||
(@pxref{Understanding}) when invoked with option @option{--verbose}, and DOT
|
(@pxref{Understanding, ,Understanding Your Parser}) when invoked
|
||||||
(@pxref{Graphviz}) when invoked with option @option{--graph}. However,
|
with option @option{--verbose}, and DOT
|
||||||
|
(@pxref{Graphviz,, Visualizing Your Parser}) when invoked with
|
||||||
|
option @option{--graph}. However,
|
||||||
another alternative is to output an XML file that may then be, with
|
another alternative is to output an XML file that may then be, with
|
||||||
@command{xsltproc}, rendered as either a raw text format equivalent to the
|
@command{xsltproc}, rendered as either a raw text format equivalent to the
|
||||||
verbose file, or as an HTML version of the same file, with clickable
|
verbose file, or as an HTML version of the same file, with clickable
|
||||||
@@ -8743,7 +8888,7 @@ transitions, or even as a DOT. The @file{.output} and DOT files obtained via
|
|||||||
XSLT have no difference whatsoever with those obtained by invoking
|
XSLT have no difference whatsoever with those obtained by invoking
|
||||||
@command{bison} with options @option{--verbose} or @option{--graph}.
|
@command{bison} with options @option{--verbose} or @option{--graph}.
|
||||||
|
|
||||||
The textual file is generated when the options @option{-x} or
|
The XML file is generated when the options @option{-x} or
|
||||||
@option{--xml[=FILE]} are specified, see @ref{Invocation,,Invoking Bison}.
|
@option{--xml[=FILE]} are specified, see @ref{Invocation,,Invoking Bison}.
|
||||||
If not specified, its name is made by removing @samp{.tab.c} or @samp{.c}
|
If not specified, its name is made by removing @samp{.tab.c} or @samp{.c}
|
||||||
from the parser implementation file name, and adding @samp{.xml} instead.
|
from the parser implementation file name, and adding @samp{.xml} instead.
|
||||||
@@ -8757,19 +8902,19 @@ files to apply to the XML file. Their names are non-ambiguous:
|
|||||||
@item xml2dot.xsl
|
@item xml2dot.xsl
|
||||||
Used to output a copy of the DOT visualization of the automaton.
|
Used to output a copy of the DOT visualization of the automaton.
|
||||||
@item xml2text.xsl
|
@item xml2text.xsl
|
||||||
Used to output a copy of the .output file.
|
Used to output a copy of the @samp{.output} file.
|
||||||
@item xml2xhtml.xsl
|
@item xml2xhtml.xsl
|
||||||
Used to output an xhtml enhancement of the .output file.
|
Used to output an xhtml enhancement of the @samp{.output} file.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
Sample usage (requires @code{xsltproc}):
|
Sample usage (requires @command{xsltproc}):
|
||||||
@example
|
@example
|
||||||
$ bison -x input.y
|
$ bison -x gr.y
|
||||||
@group
|
@group
|
||||||
$ bison --print-datadir
|
$ bison --print-datadir
|
||||||
/usr/local/share/bison
|
/usr/local/share/bison
|
||||||
@end group
|
@end group
|
||||||
$ xsltproc /usr/local/share/bison/xslt/xml2xhtml.xsl input.xml > input.html
|
$ xsltproc /usr/local/share/bison/xslt/xml2xhtml.xsl gr.xml >gr.html
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@c ================================================= Tracing
|
@c ================================================= Tracing
|
||||||
@@ -8960,7 +9105,7 @@ Entering state 24
|
|||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
The previous reduction demonstrates the @code{%printer} directive for
|
The previous reduction demonstrates the @code{%printer} directive for
|
||||||
@code{<val>}: both the token @code{NUM} and the resulting non-terminal
|
@code{<val>}: both the token @code{NUM} and the resulting nonterminal
|
||||||
@code{exp} have @samp{1} as value.
|
@code{exp} have @samp{1} as value.
|
||||||
|
|
||||||
@example
|
@example
|
||||||
@@ -9250,7 +9395,7 @@ Show caret errors, in a manner similar to GCC's
|
|||||||
@option{-fdiagnostics-show-caret}, or Clang's @option{-fcaret-diagnotics}. The
|
@option{-fdiagnostics-show-caret}, or Clang's @option{-fcaret-diagnotics}. The
|
||||||
location provided with the message is used to quote the corresponding line of
|
location provided with the message is used to quote the corresponding line of
|
||||||
the source file, underlining the important part of it with carets (^). Here is
|
the source file, underlining the important part of it with carets (^). Here is
|
||||||
an example, using the following file @file{input.y}:
|
an example, using the following file @file{in.y}:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
%type <ival> exp
|
%type <ival> exp
|
||||||
@@ -9262,27 +9407,27 @@ When invoked with @option{-fcaret}, Bison will report:
|
|||||||
|
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
input.y:3.20-23: error: ambiguous reference: '$exp'
|
in.y:3.20-23: error: ambiguous reference: '$exp'
|
||||||
exp: exp '+' exp @{ $exp = $1 + $2; @};
|
exp: exp '+' exp @{ $exp = $1 + $2; @};
|
||||||
^^^^
|
^^^^
|
||||||
@end group
|
@end group
|
||||||
@group
|
@group
|
||||||
input.y:3.1-3: refers to: $exp at $$
|
in.y:3.1-3: refers to: $exp at $$
|
||||||
exp: exp '+' exp @{ $exp = $1 + $2; @};
|
exp: exp '+' exp @{ $exp = $1 + $2; @};
|
||||||
^^^
|
^^^
|
||||||
@end group
|
@end group
|
||||||
@group
|
@group
|
||||||
input.y:3.6-8: refers to: $exp at $1
|
in.y:3.6-8: refers to: $exp at $1
|
||||||
exp: exp '+' exp @{ $exp = $1 + $2; @};
|
exp: exp '+' exp @{ $exp = $1 + $2; @};
|
||||||
^^^
|
^^^
|
||||||
@end group
|
@end group
|
||||||
@group
|
@group
|
||||||
input.y:3.14-16: refers to: $exp at $3
|
in.y:3.14-16: refers to: $exp at $3
|
||||||
exp: exp '+' exp @{ $exp = $1 + $2; @};
|
exp: exp '+' exp @{ $exp = $1 + $2; @};
|
||||||
^^^
|
^^^
|
||||||
@end group
|
@end group
|
||||||
@group
|
@group
|
||||||
input.y:3.32-33: error: $2 of 'exp' has no declared type
|
in.y:3.32-33: error: $2 of 'exp' has no declared type
|
||||||
exp: exp '+' exp @{ $exp = $1 + $2; @};
|
exp: exp '+' exp @{ $exp = $1 + $2; @};
|
||||||
^^
|
^^
|
||||||
@end group
|
@end group
|
||||||
@@ -10295,19 +10440,30 @@ It is convenient to use a typedef to shorten
|
|||||||
%@{
|
%@{
|
||||||
typedef yy::calcxx_parser::token token;
|
typedef yy::calcxx_parser::token token;
|
||||||
%@}
|
%@}
|
||||||
/* Convert ints to the actual type of tokens. */
|
/* Convert ints to the actual type of tokens. */
|
||||||
[-+*/] return yy::calcxx_parser::token_type (yytext[0]);
|
[-+*/] return yy::calcxx_parser::token_type (yytext[0]);
|
||||||
":=" return token::ASSIGN;
|
|
||||||
@{int@} @{
|
":=" return token::ASSIGN;
|
||||||
errno = 0;
|
|
||||||
long n = strtol (yytext, NULL, 10);
|
@group
|
||||||
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
|
@{int@} @{
|
||||||
driver.error (*yylloc, "integer is out of range");
|
errno = 0;
|
||||||
yylval->ival = n;
|
long n = strtol (yytext, NULL, 10);
|
||||||
return token::NUMBER;
|
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
|
||||||
@}
|
driver.error (*yylloc, "integer is out of range");
|
||||||
@{id@} yylval->sval = new std::string (yytext); return token::IDENTIFIER;
|
yylval->ival = n;
|
||||||
. driver.error (*yylloc, "invalid character");
|
return token::NUMBER;
|
||||||
|
@}
|
||||||
|
@end group
|
||||||
|
|
||||||
|
@group
|
||||||
|
@{id@} @{
|
||||||
|
yylval->sval = new std::string (yytext);
|
||||||
|
return token::IDENTIFIER;
|
||||||
|
@}
|
||||||
|
@end group
|
||||||
|
|
||||||
|
. driver.error (*yylloc, "invalid character");
|
||||||
%%
|
%%
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@@ -11353,18 +11509,23 @@ In an action, the location of the left-hand side of the rule.
|
|||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Variable} @@@var{n}
|
@deffn {Variable} @@@var{n}
|
||||||
|
@deffnx {Symbol} @@@var{n}
|
||||||
In an action, the location of the @var{n}-th symbol of the right-hand side
|
In an action, the location of the @var{n}-th symbol of the right-hand side
|
||||||
of the rule. @xref{Tracking Locations}.
|
of the rule. @xref{Tracking Locations}.
|
||||||
|
|
||||||
|
In a grammar, the Bison-generated nonterminal symbol for a mid-rule action
|
||||||
|
with a semantical value. @xref{Mid-Rule Action Translation}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Variable} @@@var{name}
|
@deffn {Variable} @@@var{name}
|
||||||
In an action, the location of a symbol addressed by name. @xref{Tracking
|
@deffnx {Variable} @@[@var{name}]
|
||||||
Locations}.
|
In an action, the location of a symbol addressed by @var{name}.
|
||||||
|
@xref{Tracking Locations}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Variable} @@[@var{name}]
|
@deffn {Symbol} $@@@var{n}
|
||||||
In an action, the location of a symbol addressed by name. @xref{Tracking
|
In a grammar, the Bison-generated nonterminal symbol for a mid-rule action
|
||||||
Locations}.
|
with no semantical value. @xref{Mid-Rule Action Translation}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Variable} $$
|
@deffn {Variable} $$
|
||||||
@@ -11378,12 +11539,8 @@ right-hand side of the rule. @xref{Actions}.
|
|||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Variable} $@var{name}
|
@deffn {Variable} $@var{name}
|
||||||
In an action, the semantic value of a symbol addressed by name.
|
@deffnx {Variable} $[@var{name}]
|
||||||
@xref{Actions}.
|
In an action, the semantic value of a symbol addressed by @var{name}.
|
||||||
@end deffn
|
|
||||||
|
|
||||||
@deffn {Variable} $[@var{name}]
|
|
||||||
In an action, the semantic value of a symbol addressed by name.
|
|
||||||
@xref{Actions}.
|
@xref{Actions}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@@ -11401,8 +11558,9 @@ the grammar file. @xref{Grammar Outline, ,Outline of a Bison
|
|||||||
Grammar}.
|
Grammar}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Construct} /*@dots{}*/
|
@deffn {Construct} /* @dots{} */
|
||||||
Comment delimiters, as in C.
|
@deffnx {Construct} // @dots{}
|
||||||
|
Comments, as in C/C++.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Delimiter} :
|
@deffn {Delimiter} :
|
||||||
@@ -11885,7 +12043,7 @@ Data type of semantic values; @code{int} by default.
|
|||||||
@item Accepting state
|
@item Accepting state
|
||||||
A state whose only action is the accept action.
|
A state whose only action is the accept action.
|
||||||
The accepting state is thus a consistent state.
|
The accepting state is thus a consistent state.
|
||||||
@xref{Understanding,,}.
|
@xref{Understanding, ,Understanding Your Parser}.
|
||||||
|
|
||||||
@item Backus-Naur Form (BNF; also called ``Backus Normal Form'')
|
@item Backus-Naur Form (BNF; also called ``Backus Normal Form'')
|
||||||
Formal method of specifying context-free grammars originally proposed
|
Formal method of specifying context-free grammars originally proposed
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
// Generated by GNU Bison 2.6.90.
|
||||||
|
// Report bugs to <[email protected]>.
|
||||||
|
// Home page: <http://www.gnu.org/software/bison/>.
|
||||||
|
|
||||||
|
digraph "/tmp/fo.y"
|
||||||
|
{
|
||||||
|
node [fontname = courier, shape = box, colorscheme = paired6]
|
||||||
|
edge [fontname = courier]
|
||||||
|
|
||||||
|
0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a \";\"\l 2 | . b \".\"\l 3 a: . \"0\"\l 4 b: . \"0\"\l"]
|
||||||
|
0 -> 1 [style=solid label="\"0\""]
|
||||||
|
0 -> 2 [style=dashed label="exp"]
|
||||||
|
0 -> 3 [style=dashed label="a"]
|
||||||
|
0 -> 4 [style=dashed label="b"]
|
||||||
|
1 [label="State 1\n\l 3 a: \"0\" . [\";\"]\l 4 b: \"0\" . [\".\"]\l"]
|
||||||
|
1 -> "1R3" [style=solid]
|
||||||
|
"1R3" [label="R3", fillcolor=3, shape=diamond, style=filled]
|
||||||
|
1 -> "1R4" [label="[\".\"]", style=solid]
|
||||||
|
"1R4" [label="R4", fillcolor=3, shape=diamond, style=filled]
|
||||||
|
2 [label="State 2\n\l 0 $accept: exp . $end\l"]
|
||||||
|
2 -> 5 [style=solid label="$end"]
|
||||||
|
3 [label="State 3\n\l 1 exp: a . \";\"\l"]
|
||||||
|
3 -> 6 [style=solid label="\";\""]
|
||||||
|
4 [label="State 4\n\l 2 exp: b . \".\"\l"]
|
||||||
|
4 -> 7 [style=solid label="\".\""]
|
||||||
|
5 [label="State 5\n\l 0 $accept: exp $end .\l"]
|
||||||
|
5 -> "5R0" [style=solid]
|
||||||
|
"5R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
|
||||||
|
6 [label="State 6\n\l 1 exp: a \";\" .\l"]
|
||||||
|
6 -> "6R1" [style=solid]
|
||||||
|
"6R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
|
||||||
|
7 [label="State 7\n\l 2 exp: b \".\" .\l"]
|
||||||
|
7 -> "7R2" [style=solid]
|
||||||
|
"7R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
%%
|
||||||
|
exp: a ";" | b ".";
|
||||||
|
a: "0";
|
||||||
|
b: "0";
|
||||||
+1
-1
Submodule gnulib updated: c457e702ba...4a8c422f31
+26
-18
@@ -24,6 +24,7 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_C_COMPILER], [
|
|||||||
int test_array[CHAR_BIT];]])],
|
int test_array[CHAR_BIT];]])],
|
||||||
[],
|
[],
|
||||||
[AC_MSG_FAILURE([cannot compile a simple C program])])
|
[AC_MSG_FAILURE([cannot compile a simple C program])])
|
||||||
|
AC_SUBST([BISON_C_WORKS], [:])
|
||||||
])
|
])
|
||||||
|
|
||||||
# BISON_CHECK_WITH_POSIXLY_CORRECT(CODE)
|
# BISON_CHECK_WITH_POSIXLY_CORRECT(CODE)
|
||||||
@@ -47,25 +48,32 @@ case $gl_had_POSIXLY_CORRECT in
|
|||||||
esac
|
esac
|
||||||
])
|
])
|
||||||
|
|
||||||
# BISON_C_COMPILER_POSIXLY_CORRECT
|
# BISON_LANG_COMPILER_POSIXLY_CORRECT
|
||||||
# --------------------------------
|
# -----------------------------------
|
||||||
# Whether the compiler supports -g in POSIXLY_CORRECT mode. clang-2.9
|
# Whether the compiler for the current language supports -g in
|
||||||
# on OS X does not, because "clang-mp-2.9 -o test -g test.c" launches
|
# POSIXLY_CORRECT mode. clang-2.9 on OS X does not, because
|
||||||
# "/usr/bin/dsymutil test -o test.dSYM" which fails with "error:
|
# "clang-mp-2.9 -o test -g test.c" launches "/usr/bin/dsymutil test -o
|
||||||
# unable to open executable '-o'".
|
# test.dSYM" which fails with "error: unable to open executable '-o'".
|
||||||
#
|
#
|
||||||
# Sets C_COMPILER_POSIXLY_CORRECT to true/false.
|
# Sets <LANG>_COMPILER_POSIXLY_CORRECT to true/false.
|
||||||
AC_DEFUN([BISON_C_COMPILER_POSIXLY_CORRECT],
|
AC_DEFUN([BISON_LANG_COMPILER_POSIXLY_CORRECT],
|
||||||
[AC_CACHE_CHECK([whether $CC supports POSIXLY_CORRECT=1],
|
[AC_CACHE_CHECK([whether $_AC_CC supports POSIXLY_CORRECT=1],
|
||||||
[bison_cv_cc_supports_posixly_correct],
|
[bison_cv_[]_AC_LANG_ABBREV[]_supports_posixly_correct],
|
||||||
[BISON_CHECK_WITH_POSIXLY_CORRECT(
|
[BISON_CHECK_WITH_POSIXLY_CORRECT(
|
||||||
[AC_LANG_PUSH([C])
|
[AC_LINK_IFELSE([AC_LANG_PROGRAM],
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM],
|
[bison_cv_[]_AC_LANG_ABBREV[]_supports_posixly_correct=yes],
|
||||||
[bison_cv_cc_supports_posixly_correct=yes],
|
[bison_cv_[]_AC_LANG_ABBREV[]_supports_posixly_correct=no])])])
|
||||||
[bison_cv_cc_supports_posixly_correct=no])
|
case $bison_cv_[]_AC_LANG_ABBREV[]_supports_posixly_correct in
|
||||||
AC_LANG_POP([C])])])
|
yes) AC_SUBST(_AC_LANG_PREFIX[_COMPILER_POSIXLY_CORRECT], [true]) ;;
|
||||||
case $bison_cv_cc_supports_posixly_correct in
|
no) AC_SUBST(_AC_LANG_PREFIX[_COMPILER_POSIXLY_CORRECT], [false]);;
|
||||||
yes) AC_SUBST([C_COMPILER_POSIXLY_CORRECT], [true]) ;;
|
|
||||||
no) AC_SUBST([C_COMPILER_POSIXLY_CORRECT], [false]);;
|
|
||||||
esac
|
esac
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# BISON_C_COMPILER_POSIXLY_CORRECT
|
||||||
|
# --------------------------------
|
||||||
|
# Whether the C compiler supports -g in POSIXLY_CORRECT mode.
|
||||||
|
AC_DEFUN([BISON_C_COMPILER_POSIXLY_CORRECT],
|
||||||
|
[AC_LANG_PUSH([C])
|
||||||
|
BISON_LANG_COMPILER_POSIXLY_CORRECT
|
||||||
|
AC_LANG_POP([C])
|
||||||
|
])
|
||||||
|
|||||||
@@ -58,3 +58,12 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_CXX_COMPILER],
|
|||||||
AC_SUBST([BISON_CXX_WORKS])
|
AC_SUBST([BISON_CXX_WORKS])
|
||||||
AM_CONDITIONAL(BISON_CXX_WORKS, test $bison_cv_cxx_works = yes)
|
AM_CONDITIONAL(BISON_CXX_WORKS, test $bison_cv_cxx_works = yes)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# BISON_CXX_COMPILER_POSIXLY_CORRECT
|
||||||
|
# ----------------------------------
|
||||||
|
# Whether the C++ compiler supports -g in POSIXLY_CORRECT mode.
|
||||||
|
AC_DEFUN([BISON_CXX_COMPILER_POSIXLY_CORRECT],
|
||||||
|
[AC_LANG_PUSH([C++])
|
||||||
|
BISON_LANG_COMPILER_POSIXLY_CORRECT
|
||||||
|
AC_LANG_POP([C++])
|
||||||
|
])
|
||||||
|
|||||||
+31
-21
@@ -24,38 +24,48 @@
|
|||||||
|
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
|
||||||
/// Begin a Dot graph.
|
/** Begin a Dot graph.
|
||||||
/// \param fout output stream.
|
*
|
||||||
|
* \param fout output stream.
|
||||||
|
*/
|
||||||
void start_graph (FILE *fout);
|
void start_graph (FILE *fout);
|
||||||
|
|
||||||
/// Output a Dot node.
|
/** Output a Dot node.
|
||||||
/// \param id identifier of the node
|
*
|
||||||
/// \param label human readable label of the node (no Dot escaping needed).
|
* \param id identifier of the node
|
||||||
/// \param fout output stream.
|
* \param label human readable label of the node (no Dot escaping needed).
|
||||||
|
* \param fout output stream.
|
||||||
|
*/
|
||||||
void output_node (int id, char const *label, FILE *fout);
|
void output_node (int id, char const *label, FILE *fout);
|
||||||
|
|
||||||
/// Output a Dot edge.
|
/** Output a Dot edge.
|
||||||
/// \param source id of the source node
|
* \param source id of the source node
|
||||||
/// \param destination id of the target node
|
* \param destination id of the target node
|
||||||
/// \param label human readable label of the edge
|
* \param label human readable label of the edge
|
||||||
/// (no Dot escaping needed). Can be 0.
|
* (no Dot escaping needed). Can be 0.
|
||||||
/// \param style Dot style of the edge (e.g., "dotted" or "solid").
|
* \param style Dot style of the edge (e.g., "dotted" or "solid").
|
||||||
/// \param fout output stream.
|
* \param fout output stream.
|
||||||
|
*/
|
||||||
void output_edge (int source, int destination, char const *label,
|
void output_edge (int source, int destination, char const *label,
|
||||||
char const *style, FILE *fout);
|
char const *style, FILE *fout);
|
||||||
|
|
||||||
/// Output a reduction.
|
/** Output a reduction.
|
||||||
/// \param s current state
|
* \param s current state
|
||||||
/// \param reds the set of reductions
|
* \param reds the set of reductions
|
||||||
/// \param fout output stream.
|
* \param fout output stream.
|
||||||
|
*/
|
||||||
void output_red (state const *s, reductions const *reds, FILE *fout);
|
void output_red (state const *s, reductions const *reds, FILE *fout);
|
||||||
|
|
||||||
/// End a Dot graph.
|
/** End a Dot graph.
|
||||||
/// \param fout output stream.
|
*
|
||||||
|
* \param fout output stream.
|
||||||
|
*/
|
||||||
void finish_graph (FILE *fout);
|
void finish_graph (FILE *fout);
|
||||||
|
|
||||||
/// Escape a lookahead token.
|
/** Escape a lookahead token.
|
||||||
/// \param name the token.
|
*
|
||||||
|
* \param name the token.
|
||||||
|
*/
|
||||||
char const *escape (char const *name);
|
char const *escape (char const *name);
|
||||||
|
|
||||||
#endif /* ! GRAPHVIZ_H_ */
|
#endif /* ! GRAPHVIZ_H_ */
|
||||||
|
|||||||
+4
-4
@@ -758,8 +758,8 @@ ielr_compute_state (bitsetv follow_kernel_items, bitsetv always_follows,
|
|||||||
if (!bitset_empty_p (lookaheads[i]))
|
if (!bitset_empty_p (lookaheads[i]))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// bitset_equal_p uses the size of the first argument, so
|
/* bitset_equal_p uses the size of the first argument,
|
||||||
// lookaheads[i] must be the second argument.
|
so lookaheads[i] must be the second argument. */
|
||||||
else if (!bitset_equal_p ((*this_isocorep)->lookaheads[i],
|
else if (!bitset_equal_p ((*this_isocorep)->lookaheads[i],
|
||||||
lookaheads[i]))
|
lookaheads[i]))
|
||||||
break;
|
break;
|
||||||
@@ -1187,8 +1187,8 @@ ielr (void)
|
|||||||
free (to_state);
|
free (to_state);
|
||||||
if (lr_type == LR_TYPE__CANONICAL_LR)
|
if (lr_type == LR_TYPE__CANONICAL_LR)
|
||||||
{
|
{
|
||||||
// Reduction lookaheads are computed in ielr_split_states above but are
|
/* Reduction lookaheads are computed in ielr_split_states above
|
||||||
// timed as part of phase 4.
|
but are timed as part of phase 4. */
|
||||||
set_goto_map ();
|
set_goto_map ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
+2
-2
@@ -325,9 +325,9 @@ grammar_rule_check (const symbol_list *r)
|
|||||||
void (*warn_at_ptr)(location, char const*, ...) =
|
void (*warn_at_ptr)(location, char const*, ...) =
|
||||||
midrule_warning ? midrule_value_at : warn_at;
|
midrule_warning ? midrule_value_at : warn_at;
|
||||||
if (n)
|
if (n)
|
||||||
warn_at_ptr (r->location, _("unused value: $%d"), n);
|
warn_at_ptr (l->location, _("unused value: $%d"), n);
|
||||||
else
|
else
|
||||||
warn_at_ptr (r->location, _("unset value: $$"));
|
warn_at_ptr (l->location, _("unset value: $$"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -883,7 +883,7 @@ unexpected_end (boundary start, char const *msgid, char const *token_end)
|
|||||||
loc.start = start;
|
loc.start = start;
|
||||||
loc.end = scanner_cursor;
|
loc.end = scanner_cursor;
|
||||||
token_end = quote (token_end);
|
token_end = quote (token_end);
|
||||||
// Instead of '\'', display "'".
|
/* Instead of '\'', display "'". */
|
||||||
if (!strcmp (token_end, "'\\''"))
|
if (!strcmp (token_end, "'\\''"))
|
||||||
token_end = "\"'\"";
|
token_end = "\"'\"";
|
||||||
complain_at (loc, _(msgid), token_end);
|
complain_at (loc, _(msgid), token_end);
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@
|
|||||||
typedef size_t uintptr_t;
|
typedef size_t uintptr_t;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// Version mismatch.
|
/* Version mismatch. */
|
||||||
# define EX_MISMATCH 63
|
# define EX_MISMATCH 63
|
||||||
|
|
||||||
/*---------.
|
/*---------.
|
||||||
|
|||||||
+7
-6
@@ -90,7 +90,7 @@ AT_DATA_GRAMMAR([[input.y]],
|
|||||||
%code
|
%code
|
||||||
{
|
{
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h> // getenv
|
# include <stdlib.h> /* getenv */
|
||||||
]AT_YYERROR_DECLARE[
|
]AT_YYERROR_DECLARE[
|
||||||
]AT_YYLEX_DECLARE[
|
]AT_YYLEX_DECLARE[
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ AT_DATA_GRAMMAR([[input.y]],
|
|||||||
%code
|
%code
|
||||||
{
|
{
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h> // getenv
|
# include <stdlib.h> /* getenv */
|
||||||
]AT_YYERROR_DECLARE[
|
]AT_YYERROR_DECLARE[
|
||||||
]AT_YYLEX_DECLARE[
|
]AT_YYLEX_DECLARE[
|
||||||
}
|
}
|
||||||
@@ -223,6 +223,7 @@ main (void)
|
|||||||
|
|
||||||
TEST(7, 2, 0, 2);
|
TEST(7, 2, 0, 2);
|
||||||
TEST(8, 0, 8, 0);
|
TEST(8, 0, 8, 0);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
|
||||||
@@ -1301,16 +1302,16 @@ AT_BISON_OPTION_POPDEFS
|
|||||||
|
|
||||||
AT_BISON_CHECK([-o input.c input.y], 0,,
|
AT_BISON_CHECK([-o input.c input.y], 0,,
|
||||||
[[input.y:33.3-23: warning: unset value: $$
|
[[input.y:33.3-23: warning: unset value: $$
|
||||||
input.y:30.3-35.37: warning: unused value: $3
|
input.y:32.3-23: warning: unused value: $3
|
||||||
]])
|
]])
|
||||||
|
|
||||||
AT_BISON_CHECK([-fcaret -o input.c input.y], 0,,
|
AT_BISON_CHECK([-fcaret -o input.c input.y], 0,,
|
||||||
[[input.y:33.3-23: warning: unset value: $$
|
[[input.y:33.3-23: warning: unset value: $$
|
||||||
{ @$ = 4; } // Only used.
|
{ @$ = 4; } // Only used.
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^
|
||||||
input.y:30.3-35.37: warning: unused value: $3
|
input.y:32.3-23: warning: unused value: $3
|
||||||
{ @$ = 1; } // Not set or used.
|
{ USE ($$); @$ = 3; } // Only set.
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^
|
||||||
]])
|
]])
|
||||||
|
|
||||||
AT_COMPILE([input])
|
AT_COMPILE([input])
|
||||||
|
|||||||
+23
-11
@@ -19,6 +19,15 @@
|
|||||||
# We need `config.h'.
|
# We need `config.h'.
|
||||||
CPPFLAGS="-I$abs_top_builddir/lib @CPPFLAGS@"
|
CPPFLAGS="-I$abs_top_builddir/lib @CPPFLAGS@"
|
||||||
|
|
||||||
|
# Don't just check if $POSIXLY_CORRECT is set, as Bash, when launched
|
||||||
|
# as /bin/sh, sets the shell variable POSIXLY_CORRECT to y, but not
|
||||||
|
# the environment variable.
|
||||||
|
if env | grep '^POSIXLY_CORRECT=' >/dev/null; then
|
||||||
|
POSIXLY_CORRECT_IS_EXPORTED=true
|
||||||
|
else
|
||||||
|
POSIXLY_CORRECT_IS_EXPORTED=false
|
||||||
|
fi
|
||||||
|
|
||||||
## ------------------- ##
|
## ------------------- ##
|
||||||
## C/C++ Compilation. ##
|
## C/C++ Compilation. ##
|
||||||
## ------------------- ##
|
## ------------------- ##
|
||||||
@@ -38,15 +47,28 @@ NO_WERROR_CXXFLAGS='@CXXFLAGS@ @WARN_CXXFLAGS@ @WARN_CXXFLAGS_TEST@'
|
|||||||
CFLAGS="$NO_WERROR_CFLAGS @WERROR_CFLAGS@"
|
CFLAGS="$NO_WERROR_CFLAGS @WERROR_CFLAGS@"
|
||||||
CXXFLAGS="$NO_WERROR_CXXFLAGS @WERROR_CXXFLAGS@"
|
CXXFLAGS="$NO_WERROR_CXXFLAGS @WERROR_CXXFLAGS@"
|
||||||
|
|
||||||
# If 'exit 77'; skip all C++ tests; otherwise ':'.
|
# If 'exit 77'; skip all C/C++ tests; otherwise ':'.
|
||||||
|
BISON_C_WORKS='@BISON_C_WORKS@'
|
||||||
BISON_CXX_WORKS='@BISON_CXX_WORKS@'
|
BISON_CXX_WORKS='@BISON_CXX_WORKS@'
|
||||||
|
|
||||||
|
# Whether the compiler supports POSIXLY_CORRECT defined.
|
||||||
|
: ${C_COMPILER_POSIXLY_CORRECT='@C_COMPILER_POSIXLY_CORRECT@'}
|
||||||
|
: ${CXX_COMPILER_POSIXLY_CORRECT='@CXX_COMPILER_POSIXLY_CORRECT@'}
|
||||||
|
|
||||||
|
if $POSIXLY_CORRECT_IS_EXPORTED; then
|
||||||
|
$C_COMPILER_POSIXLY_CORRECT ||
|
||||||
|
BISON_C_WORKS="as_fn_error 77 POSIXLY_CORRECT"
|
||||||
|
$CXX_COMPILER_POSIXLY_CORRECT ||
|
||||||
|
BISON_CXX_WORKS="as_fn_error 77 POSIXLY_CORRECT"
|
||||||
|
fi
|
||||||
|
|
||||||
# Handle --compile-c-with-cxx here, once CXX and CXXFLAGS are known.
|
# Handle --compile-c-with-cxx here, once CXX and CXXFLAGS are known.
|
||||||
if "$at_arg_compile_c_with_cxx"; then
|
if "$at_arg_compile_c_with_cxx"; then
|
||||||
CC_IS_CXX=1
|
CC_IS_CXX=1
|
||||||
CC=$CXX
|
CC=$CXX
|
||||||
NO_WERROR_CFLAGS=$NO_WERROR_CXXFLAGS
|
NO_WERROR_CFLAGS=$NO_WERROR_CXXFLAGS
|
||||||
CFLAGS=$CXXFLAGS
|
CFLAGS=$CXXFLAGS
|
||||||
|
BISON_C_WORKS=$BISON_CXX_WORKS
|
||||||
else
|
else
|
||||||
CC_IS_CXX=0
|
CC_IS_CXX=0
|
||||||
fi
|
fi
|
||||||
@@ -79,13 +101,3 @@ LIBS="$abs_top_builddir/lib/libbison.a @LIBS@ @INTLLIBS@"
|
|||||||
: ${XSLTPROC='@XSLTPROC@'}
|
: ${XSLTPROC='@XSLTPROC@'}
|
||||||
|
|
||||||
: ${PERL='@PERL@'}
|
: ${PERL='@PERL@'}
|
||||||
|
|
||||||
# Don't just check if $POSIXLY_CORRECT is set, as Bash, when launched
|
|
||||||
# as /bin/sh, sets the shell variable POSIXLY_CORRECT to y, but not
|
|
||||||
# the environment variable.
|
|
||||||
: ${C_COMPILER_POSIXLY_CORRECT='@C_COMPILER_POSIXLY_CORRECT@'}
|
|
||||||
if env | grep '^POSIXLY_CORRECT=' >/dev/null; then
|
|
||||||
POSIXLY_CORRECT_IS_EXPORTED=true
|
|
||||||
else
|
|
||||||
POSIXLY_CORRECT_IS_EXPORTED=false
|
|
||||||
fi
|
|
||||||
|
|||||||
+52
-50
@@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
AT_BANNER([[GLR Regression Tests]])
|
AT_BANNER([[GLR Regression Tests]])
|
||||||
|
|
||||||
## --------------------------- ##
|
## ---------------------------- ##
|
||||||
## Badly Collapsed GLR States. ##
|
## Badly Collapsed GLR States. ##
|
||||||
## --------------------------- ##
|
## ---------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([Badly Collapsed GLR States])
|
AT_SETUP([Badly Collapsed GLR States])
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *input = NULL;
|
const char *input = YY_NULL;
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, const char* argv[])
|
main (int argc, const char* argv[])
|
||||||
@@ -105,9 +105,9 @@ E -> E 'P' E
|
|||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
## ------------------------------------------------------------ ##
|
## -------------------------------------------------------------- ##
|
||||||
## Improper handling of embedded actions and $-N in GLR parsers ##
|
## Improper handling of embedded actions and $-N in GLR parsers. ##
|
||||||
## ------------------------------------------------------------ ##
|
## -------------------------------------------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([Improper handling of embedded actions and dollar(-N) in GLR parsers])
|
AT_SETUP([Improper handling of embedded actions and dollar(-N) in GLR parsers])
|
||||||
|
|
||||||
@@ -195,10 +195,11 @@ yylex (void)
|
|||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
int res;
|
||||||
input = stdin;
|
input = stdin;
|
||||||
if (argc == 2 && !(input = fopen (argv[1], "r")))
|
if (argc == 2 && !(input = fopen (argv[1], "r")))
|
||||||
return 3;
|
return 3;
|
||||||
int res = yyparse ();
|
res = yyparse ();
|
||||||
if (argc == 2 && fclose (input))
|
if (argc == 2 && fclose (input))
|
||||||
return 4;
|
return 4;
|
||||||
return res;
|
return res;
|
||||||
@@ -236,9 +237,9 @@ AT_PARSER_CHECK([[./glr-regr2a input3.txt]], 0,
|
|||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
## ------------------------------------------------------------ ##
|
## --------------------------------------------- ##
|
||||||
## Improper merging of GLR delayed action sets ##
|
## Improper merging of GLR delayed action sets. ##
|
||||||
## ------------------------------------------------------------ ##
|
## --------------------------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([Improper merging of GLR delayed action sets])
|
AT_SETUP([Improper merging of GLR delayed action sets])
|
||||||
|
|
||||||
@@ -327,10 +328,11 @@ int yylex (void)
|
|||||||
int
|
int
|
||||||
main(int argc, char* argv[])
|
main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
int res;
|
||||||
input = stdin;
|
input = stdin;
|
||||||
if (argc == 2 && !(input = fopen (argv[1], "r")))
|
if (argc == 2 && !(input = fopen (argv[1], "r")))
|
||||||
return 3;
|
return 3;
|
||||||
int res = yyparse ();
|
res = yyparse ();
|
||||||
if (argc == 2 && fclose (input))
|
if (argc == 2 && fclose (input))
|
||||||
return 4;
|
return 4;
|
||||||
return res;
|
return res;
|
||||||
@@ -354,10 +356,10 @@ AT_PARSER_CHECK([[./glr-regr3 input.txt]],
|
|||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
## ------------------------------------------------------------------------- ##
|
## ---------------------------------------------------------------------- ##
|
||||||
## Duplicate representation of merged trees. See ##
|
## Duplicate representation of merged trees. See ##
|
||||||
## <http://lists.gnu.org/archive/html/help-bison/2005-07/msg00013.html>. ##
|
## <http://lists.gnu.org/archive/html/help-bison/2005-07/msg00013.html>. ##
|
||||||
## ------------------------------------------------------------------------- ##
|
## ---------------------------------------------------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([Duplicate representation of merged trees])
|
AT_SETUP([Duplicate representation of merged trees])
|
||||||
|
|
||||||
@@ -445,10 +447,10 @@ AT_PARSER_CHECK([[./glr-regr4]], 0,
|
|||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
## -------------------------------------------------------------------------- ##
|
## ------------------------------------------------------------------------- ##
|
||||||
## User destructor for unresolved GLR semantic value. See ##
|
## User destructor for unresolved GLR semantic value. See ##
|
||||||
## <http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00016.html>. ##
|
## <http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00016.html>. ##
|
||||||
## -------------------------------------------------------------------------- ##
|
## ------------------------------------------------------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([User destructor for unresolved GLR semantic value])
|
AT_SETUP([User destructor for unresolved GLR semantic value])
|
||||||
|
|
||||||
@@ -505,10 +507,10 @@ AT_PARSER_CHECK([[./glr-regr5]], 0, [],
|
|||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
## -------------------------------------------------------------------------- ##
|
## ------------------------------------------------------------------------- ##
|
||||||
## User destructor after an error during a split parse. See ##
|
## User destructor after an error during a split parse. See ##
|
||||||
## <http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00029.html>. ##
|
## <http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00029.html>. ##
|
||||||
## -------------------------------------------------------------------------- ##
|
## ------------------------------------------------------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([User destructor after an error during a split parse])
|
AT_SETUP([User destructor after an error during a split parse])
|
||||||
|
|
||||||
@@ -560,7 +562,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
|
|
||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------------------------------- ##
|
||||||
## Duplicated user destructor for lookahead. See ##
|
## Duplicated user destructor for lookahead. See ##
|
||||||
## <http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00035.html>. ##
|
## <http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00035.html>. ##
|
||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------------------------------- ##
|
||||||
|
|
||||||
@@ -743,7 +745,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
|
|
||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------------------------------- ##
|
||||||
## No users destructors if stack 0 deleted. See ##
|
## No users destructors if stack 0 deleted. See ##
|
||||||
## <http://lists.gnu.org/archive/html/bison-patches/2005-09/msg00109.html>. ##
|
## <http://lists.gnu.org/archive/html/bison-patches/2005-09/msg00109.html>. ##
|
||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------------------------------- ##
|
||||||
|
|
||||||
@@ -820,9 +822,9 @@ AT_PARSER_CHECK([[./glr-regr9]], 0, [],
|
|||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------------ ##
|
||||||
## Corrupted semantic options if user action cuts parse. ##
|
## Corrupted semantic options if user action cuts parse. ##
|
||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------------ ##
|
||||||
|
|
||||||
AT_SETUP([Corrupted semantic options if user action cuts parse])
|
AT_SETUP([Corrupted semantic options if user action cuts parse])
|
||||||
|
|
||||||
@@ -874,9 +876,9 @@ AT_PARSER_CHECK([[./glr-regr10]], 0, [], [])
|
|||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
## ------------------------------------------------------------------------- ##
|
## --------------------------------------------------- ##
|
||||||
## Undesirable destructors if user action cuts parse. ##
|
## Undesirable destructors if user action cuts parse. ##
|
||||||
## ------------------------------------------------------------------------- ##
|
## --------------------------------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([Undesirable destructors if user action cuts parse])
|
AT_SETUP([Undesirable destructors if user action cuts parse])
|
||||||
|
|
||||||
@@ -932,9 +934,9 @@ AT_PARSER_CHECK([[./glr-regr11]], 0, [], [])
|
|||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
## ------------------------------------------------------------------------- ##
|
## -------------------------------------------------- ##
|
||||||
## Leaked semantic values if user action cuts parse. ##
|
## Leaked semantic values if user action cuts parse. ##
|
||||||
## ------------------------------------------------------------------------- ##
|
## -------------------------------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([Leaked semantic values if user action cuts parse])
|
AT_SETUP([Leaked semantic values if user action cuts parse])
|
||||||
|
|
||||||
@@ -1179,9 +1181,9 @@ start <- defstate_init defstate_shift 'b':
|
|||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------- ##
|
||||||
## Incorrect lookahead during nondeterministic GLR. ##
|
## Incorrect lookahead during nondeterministic GLR. ##
|
||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([Incorrect lookahead during nondeterministic GLR])
|
AT_SETUP([Incorrect lookahead during nondeterministic GLR])
|
||||||
|
|
||||||
@@ -1396,9 +1398,9 @@ start <- merge 'c' stack_explosion:
|
|||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------- ##
|
||||||
## Leaked semantic values when reporting ambiguity. ##
|
## Leaked semantic values when reporting ambiguity. ##
|
||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([Leaked semantic values when reporting ambiguity])
|
AT_SETUP([Leaked semantic values when reporting ambiguity])
|
||||||
|
|
||||||
@@ -1478,9 +1480,9 @@ AT_PARSER_CHECK([[./glr-regr15]], 0, [],
|
|||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------------------ ##
|
||||||
## Leaked lookahead after nondeterministic parse syntax error. ##
|
## Leaked lookahead after nondeterministic parse syntax error. ##
|
||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------------------ ##
|
||||||
|
|
||||||
AT_SETUP([Leaked lookahead after nondeterministic parse syntax error])
|
AT_SETUP([Leaked lookahead after nondeterministic parse syntax error])
|
||||||
|
|
||||||
@@ -1538,9 +1540,9 @@ AT_PARSER_CHECK([[./glr-regr16]], 0, [],
|
|||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------- ##
|
||||||
## Uninitialized location when reporting ambiguity. ##
|
## Uninitialized location when reporting ambiguity. ##
|
||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([Uninitialized location when reporting ambiguity])
|
AT_SETUP([Uninitialized location when reporting ambiguity])
|
||||||
|
|
||||||
@@ -1616,9 +1618,9 @@ AT_PARSER_CHECK([[./glr-regr17]], 0, [],
|
|||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
## -------------------------------------------------------------##
|
## ------------------------------------------------------------- ##
|
||||||
## Missed %merge type warnings when LHS type is declared later. ##
|
## Missed %merge type warnings when LHS type is declared later. ##
|
||||||
## -------------------------------------------------------------##
|
## ------------------------------------------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([Missed %merge type warnings when LHS type is declared later])
|
AT_SETUP([Missed %merge type warnings when LHS type is declared later])
|
||||||
|
|
||||||
|
|||||||
+105
-38
@@ -174,42 +174,109 @@ l: INT | INT { $<integer>$ = $<integer>1; } INT { $<integer>$ = $<integer>2 + $<
|
|||||||
_AT_UNUSED_VALUES_DECLARATIONS])
|
_AT_UNUSED_VALUES_DECLARATIONS])
|
||||||
)
|
)
|
||||||
|
|
||||||
AT_BISON_CHECK(m4_ifval($2, [ --warnings=midrule-values ])[ input.y], [0], [],
|
AT_BISON_CHECK(m4_ifval($2, [--warnings=midrule-values ])[-fcaret input.y],
|
||||||
[[input.y:11.10-32: warning: unset value: $]$[
|
[0], [],
|
||||||
input.y:11.10-32: warning: unused value: $]1[
|
[[input.y:11.10-32: warning: unset value: $][$
|
||||||
input.y:11.10-32: warning: unused value: $]3[
|
a: INT | INT { } INT { } INT { };
|
||||||
input.y:11.10-32: warning: unused value: $]5[
|
^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
input.y:11.10-12: warning: unused value: $][1
|
||||||
|
a: INT | INT { } INT { } INT { };
|
||||||
|
^^^
|
||||||
|
input.y:11.18-20: warning: unused value: $][3
|
||||||
|
a: INT | INT { } INT { } INT { };
|
||||||
|
^^^
|
||||||
|
input.y:11.26-28: warning: unused value: $][5
|
||||||
|
a: INT | INT { } INT { } INT { };
|
||||||
|
^^^
|
||||||
input.y:12.9: warning: empty rule for typed nonterminal, and no action
|
input.y:12.9: warning: empty rule for typed nonterminal, and no action
|
||||||
]]m4_ifval($2, [[[input.y:13.14-20: warning: unset value: $$
|
b: INT | /* empty */;
|
||||||
input.y:13.26-41: warning: unset value: $$
|
^
|
||||||
]]])[[input.y:13.10-62: warning: unset value: $]$[
|
]]m4_ifval($2, [[[input.y:13.14-20: warning: unset value: $][$
|
||||||
input.y:13.10-62: warning: unused value: $]3[
|
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
|
||||||
input.y:13.10-62: warning: unused value: $]5[
|
^^^^^^^
|
||||||
]]m4_ifval($2, [[[input.y:14.14-16: warning: unset value: $$
|
input.y:13.26-41: warning: unset value: $][$
|
||||||
]]])[[input.y:14.10-49: warning: unset value: $]$[
|
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
|
||||||
input.y:14.10-49: warning: unused value: $]3[
|
^^^^^^^^^^^^^^^^
|
||||||
input.y:14.10-49: warning: unused value: $]5[
|
]]])[[input.y:13.10-62: warning: unset value: $][$
|
||||||
input.y:15.10-37: warning: unset value: $]$[
|
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
|
||||||
input.y:15.10-37: warning: unused value: $]3[
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
input.y:15.10-37: warning: unused value: $]5[
|
input.y:13.22-24: warning: unused value: $][3
|
||||||
input.y:17.10-58: warning: unset value: $]$[
|
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
|
||||||
input.y:17.10-58: warning: unused value: $]1[
|
^^^
|
||||||
]]m4_ifval($2, [[[input.y:17.10-58: warning: unused value: $]2[
|
input.y:13.43-45: warning: unused value: $][5
|
||||||
]]])[[input.y:17.10-58: warning: unused value: $]3[
|
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
|
||||||
]]m4_ifval($2, [[[input.y:17.10-58: warning: unused value: $]4[
|
^^^
|
||||||
]]])[[input.y:17.10-58: warning: unused value: $]5[
|
]]m4_ifval($2, [[[input.y:14.14-16: warning: unset value: $][$
|
||||||
input.y:18.10-72: warning: unset value: $]$[
|
d: INT | INT { } INT { $][1; } INT { $<integer>2; };
|
||||||
input.y:18.10-72: warning: unused value: $]1[
|
^^^
|
||||||
input.y:18.10-72: warning: unused value: $]3[
|
]]])[[input.y:14.10-49: warning: unset value: $][$
|
||||||
]]m4_ifval($2, [[[input.y:18.10-72: warning: unused value: $]4[
|
d: INT | INT { } INT { $][1; } INT { $<integer>2; };
|
||||||
]]])[[input.y:18.10-72: warning: unused value: $]5[
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
]]m4_ifval($2, [[[input.y:20.10-55: warning: unused value: $]3[
|
input.y:14.18-20: warning: unused value: $][3
|
||||||
]]])[[input.y:21.10-68: warning: unset value: $]$[
|
d: INT | INT { } INT { $][1; } INT { $<integer>2; };
|
||||||
input.y:21.10-68: warning: unused value: $]1[
|
^^^
|
||||||
input.y:21.10-68: warning: unused value: $]2[
|
input.y:14.30-32: warning: unused value: $][5
|
||||||
]]m4_ifval($2, [[[input.y:21.10-68: warning: unused value: $]4[
|
d: INT | INT { } INT { $][1; } INT { $<integer>2; };
|
||||||
]]]))])
|
^^^
|
||||||
|
input.y:15.10-37: warning: unset value: $][$
|
||||||
|
e: INT | INT { } INT { } INT { $][1; };
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
input.y:15.18-20: warning: unused value: $][3
|
||||||
|
e: INT | INT { } INT { } INT { $][1; };
|
||||||
|
^^^
|
||||||
|
input.y:15.27-29: warning: unused value: $][5
|
||||||
|
e: INT | INT { } INT { } INT { $][1; };
|
||||||
|
^^^
|
||||||
|
input.y:17.10-58: warning: unset value: $][$
|
||||||
|
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
input.y:17.10-12: warning: unused value: $][1
|
||||||
|
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
|
||||||
|
^^^
|
||||||
|
]]m4_ifval($2, [[[input.y:17.14-29: warning: unused value: $][2
|
||||||
|
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
|
||||||
|
^^^^^^^^^^^^^^^^
|
||||||
|
]]])[[input.y:17.31-33: warning: unused value: $][3
|
||||||
|
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
|
||||||
|
^^^
|
||||||
|
]]m4_ifval($2, [[[input.y:17.35-50: warning: unused value: $][4
|
||||||
|
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
|
||||||
|
^^^^^^^^^^^^^^^^
|
||||||
|
]]])[[input.y:17.52-54: warning: unused value: $][5
|
||||||
|
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
|
||||||
|
^^^
|
||||||
|
input.y:18.10-72: warning: unset value: $][$
|
||||||
|
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
input.y:18.10-12: warning: unused value: $][1
|
||||||
|
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
|
||||||
|
^^^
|
||||||
|
input.y:18.31-33: warning: unused value: $][3
|
||||||
|
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
|
||||||
|
^^^
|
||||||
|
]]m4_ifval($2, [[[input.y:18.35-64: warning: unused value: $][4
|
||||||
|
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
]]])[[input.y:18.66-68: warning: unused value: $][5
|
||||||
|
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
|
||||||
|
^^^
|
||||||
|
]]m4_ifval($2, [[[input.y:20.18-37: warning: unused value: $][3
|
||||||
|
j: INT | INT INT { $<integer>$ = 1; } { $][$ = $][1 + $][2; };
|
||||||
|
^^^^^^^^^^^^^^^^^^^^
|
||||||
|
]]])[[input.y:21.10-68: warning: unset value: $][$
|
||||||
|
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
input.y:21.10-12: warning: unused value: $][1
|
||||||
|
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
|
||||||
|
^^^
|
||||||
|
input.y:21.14-16: warning: unused value: $][2
|
||||||
|
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
|
||||||
|
^^^
|
||||||
|
]]m4_ifval($2, [[[input.y:21.35-64: warning: unused value: $][4
|
||||||
|
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
]]]))
|
||||||
|
])
|
||||||
|
|
||||||
## --------------- ##
|
## --------------- ##
|
||||||
## Unused values. ##
|
## Unused values. ##
|
||||||
@@ -353,7 +420,7 @@ tagged: { } ;
|
|||||||
|
|
||||||
AT_BISON_CHECK([input.y], [0], [],
|
AT_BISON_CHECK([input.y], [0], [],
|
||||||
[[input.y:6.8-45: warning: unset value: $$
|
[[input.y:6.8-45: warning: unset value: $$
|
||||||
input.y:6.8-45: warning: unused value: $2
|
input.y:6.12-14: warning: unused value: $2
|
||||||
input.y:7.6-8: warning: unset value: $$
|
input.y:7.6-8: warning: unset value: $$
|
||||||
]])
|
]])
|
||||||
|
|
||||||
@@ -369,7 +436,7 @@ tagged: { } ;
|
|||||||
]])
|
]])
|
||||||
|
|
||||||
AT_BISON_CHECK([input.y], [0], [],
|
AT_BISON_CHECK([input.y], [0], [],
|
||||||
[[input.y:6.8-45: warning: unused value: $4
|
[[input.y:6.23-28: warning: unused value: $4
|
||||||
input.y:8.9-11: warning: unset value: $$
|
input.y:8.9-11: warning: unset value: $$
|
||||||
]])
|
]])
|
||||||
|
|
||||||
@@ -394,7 +461,7 @@ end: { } ;
|
|||||||
|
|
||||||
AT_BISON_CHECK([input.y], [0], [],
|
AT_BISON_CHECK([input.y], [0], [],
|
||||||
[[input.y:6.8-22: warning: unset value: $$
|
[[input.y:6.8-22: warning: unset value: $$
|
||||||
input.y:6.8-22: warning: unused value: $2
|
input.y:6.12-14: warning: unused value: $2
|
||||||
input.y:7.6-8: warning: unset value: $$
|
input.y:7.6-8: warning: unset value: $$
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -600,9 +600,7 @@ m4_define([AT_QUELL_VALGRIND],
|
|||||||
# 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 ".c" appended.
|
# with trailing .o removed, and ".c" appended.
|
||||||
m4_define([AT_COMPILE],
|
m4_define([AT_COMPILE],
|
||||||
[AT_CHECK([case $POSIXLY_CORRECT_IS_EXPORTED:$C_COMPILER_POSIXLY_CORRECT in
|
[AT_CHECK([$BISON_C_WORKS], 0, ignore, ignore)
|
||||||
true:false) echo 'cannot compile properly with POSIXLY_CORRECT' && exit 77;;
|
|
||||||
esac])
|
|
||||||
AT_CHECK(m4_join([ ],
|
AT_CHECK(m4_join([ ],
|
||||||
[$CC $CFLAGS $CPPFLAGS],
|
[$CC $CFLAGS $CPPFLAGS],
|
||||||
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
|
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
|
||||||
|
|||||||
+9
-2
@@ -54,7 +54,7 @@ m4_define([AT_SYNCLINES_COMPILE],
|
|||||||
# #error "1"
|
# #error "1"
|
||||||
# ^
|
# ^
|
||||||
#
|
#
|
||||||
# And possibly distcc adds its bits.
|
# Possibly distcc adds its bits.
|
||||||
#
|
#
|
||||||
# distcc[33187] ERROR: compile (null) on localhost failed
|
# distcc[33187] ERROR: compile (null) on localhost failed
|
||||||
# syncline.c:1:2: error: #error "1"
|
# syncline.c:1:2: error: #error "1"
|
||||||
@@ -71,11 +71,18 @@ m4_define([AT_SYNCLINES_COMPILE],
|
|||||||
# #error "1"
|
# #error "1"
|
||||||
# ^
|
# ^
|
||||||
# 1 error generated.
|
# 1 error generated.
|
||||||
|
#
|
||||||
|
# When c++ is used to compiler C, we might have more messages (Clang 3.2):
|
||||||
|
#
|
||||||
|
# clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
|
||||||
|
|
||||||
AT_CHECK([[$PERL -p -0777 - stderr <<\EOF
|
AT_CHECK([[$PERL -p -0777 - stderr <<\EOF
|
||||||
# 1. Remove useless lines.
|
# 1. Remove useless lines.
|
||||||
|
|
||||||
# distcc clutter.
|
# distcc clutter.
|
||||||
s/^distcc\[\d+\] .*\n//gm;
|
s/^distcc\[\d+\] .*\n//gm;
|
||||||
|
# c vs. c++.
|
||||||
|
s/^clang: warning: treating 'c' input as 'c\+\+'.*\n//gm;
|
||||||
# Function context.
|
# Function context.
|
||||||
s/^[^:]*: In function '[^']+':\n//gm;
|
s/^[^:]*: In function '[^']+':\n//gm;
|
||||||
# Caret error.
|
# Caret error.
|
||||||
@@ -120,7 +127,7 @@ AT_BISON_OPTION_PUSHDEFS
|
|||||||
|
|
||||||
AT_DATA([syncline.c],
|
AT_DATA([syncline.c],
|
||||||
[[#error "1"
|
[[#error "1"
|
||||||
int i; // avoids -pedantic warning about an empty translation unit
|
int i; /* avoids -pedantic warning about an empty translation unit. */
|
||||||
]])
|
]])
|
||||||
|
|
||||||
AT_SYNCLINES_COMPILE([syncline.c])
|
AT_SYNCLINES_COMPILE([syncline.c])
|
||||||
|
|||||||
Reference in New Issue
Block a user