mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 10:13:03 +00:00
yacc: support parse.assert
While hacking on the computation of the automaton, I had yystate being equal to -1, and the parser loops. Let's catch this when parser.assert is enabled. * data/skeletons/yacc.c (YY_ASSERT): New. Use it. Not using the name YYASSERT, to make it clear that this is private. glr.c should probably move to YY_ASSERT too. Also, while at it, report 'Entering state...' even before growing the stacks.
This commit is contained in:
@@ -411,6 +411,15 @@ typedef short yytype_int16;
|
|||||||
|
|
||||||
]b4_attribute_define[
|
]b4_attribute_define[
|
||||||
|
|
||||||
|
]b4_parse_assert_if([[#ifdef NDEBUG
|
||||||
|
# define YY_ASSERT(E) ((void) (0 && (E)))
|
||||||
|
#else
|
||||||
|
# include <assert.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
|
# define YY_ASSERT(E) assert (E)
|
||||||
|
#endif
|
||||||
|
]],
|
||||||
|
[[#define YY_ASSERT(E) ((void) (0 && (E)))]])[
|
||||||
|
|
||||||
#if ]b4_lac_if([[1]], [[! defined yyoverflow || YYERROR_VERBOSE]])[
|
#if ]b4_lac_if([[1]], [[! defined yyoverflow || YYERROR_VERBOSE]])[
|
||||||
|
|
||||||
/* The parser invokes alloca or malloc; define the necessary symbols. */]dnl
|
/* The parser invokes alloca or malloc; define the necessary symbols. */]dnl
|
||||||
@@ -1453,6 +1462,8 @@ yynewstate:
|
|||||||
| yynewstate -- set current state (the top of the stack) to yystate. |
|
| yynewstate -- set current state (the top of the stack) to yystate. |
|
||||||
`--------------------------------------------------------------------*/
|
`--------------------------------------------------------------------*/
|
||||||
yysetstate:
|
yysetstate:
|
||||||
|
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
||||||
|
YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
|
||||||
*yyssp = (yytype_int16) yystate;
|
*yyssp = (yytype_int16) yystate;
|
||||||
|
|
||||||
if (yyss + yystacksize - 1 <= yyssp)
|
if (yyss + yystacksize - 1 <= yyssp)
|
||||||
@@ -1520,8 +1531,6 @@ yysetstate:
|
|||||||
}
|
}
|
||||||
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
|
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
|
||||||
|
|
||||||
if (yystate == YYFINAL)
|
if (yystate == YYFINAL)
|
||||||
YYACCEPT;
|
YYACCEPT;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user