mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-15 15:23:02 +00:00
* data/glr.c (yydestroyGLRState): Renamed from yydestroyStackItem.
All uses changed. Invoke user destructor after an error during a split parse (trivial change from Joel E. Denny). * tests/glr-regression.at (User destructor after an error during a split parse): New test case. Problem reported by Joel E. Denny in: http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00029.html
This commit is contained in:
11
ChangeLog
11
ChangeLog
@@ -1,3 +1,14 @@
|
|||||||
|
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
|
* data/glr.c (yydestroyGLRState): Renamed from yydestroyStackItem.
|
||||||
|
All uses changed. Invoke user destructor after an error during a
|
||||||
|
split parse (trivial change from Joel E. Denny).
|
||||||
|
|
||||||
|
* tests/glr-regression.at
|
||||||
|
(User destructor after an error during a split parse): New test case.
|
||||||
|
Problem reported by Joel E. Denny in:
|
||||||
|
http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00029.html
|
||||||
|
|
||||||
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
|
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
* README-cvs: Give URLs for recommended tools.
|
* README-cvs: Give URLs for recommended tools.
|
||||||
|
|||||||
31
data/glr.c
31
data/glr.c
@@ -886,8 +886,15 @@ yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
|
|||||||
|
|
||||||
]b4_yydestruct_generate([b4_c_ansi_function_def])[
|
]b4_yydestruct_generate([b4_c_ansi_function_def])[
|
||||||
|
|
||||||
|
/** Number of symbols composing the right hand side of rule #RULE. */
|
||||||
|
static inline int
|
||||||
|
yyrhsLength (yyRuleNum yyrule)
|
||||||
|
{
|
||||||
|
return yyr2[yyrule];
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
yydestroyStackItem (char const *yymsg, yyGLRState *yys)
|
yydestroyGLRState (char const *yymsg, yyGLRState *yys)
|
||||||
{
|
{
|
||||||
if (yys->yyresolved)
|
if (yys->yyresolved)
|
||||||
yydestruct (yymsg, yystos[yys->yylrState],
|
yydestruct (yymsg, yystos[yys->yylrState],
|
||||||
@@ -903,14 +910,18 @@ yydestroyStackItem (char const *yymsg, yyGLRState *yys)
|
|||||||
YYFPRINTF (stderr, "\n");
|
YYFPRINTF (stderr, "\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Number of symbols composing the right hand side of rule #RULE. */
|
if (yys->yysemantics.yyfirstVal)
|
||||||
static inline int
|
{
|
||||||
yyrhsLength (yyRuleNum yyrule)
|
yySemanticOption *yyoption = yys->yysemantics.yyfirstVal;
|
||||||
{
|
yyGLRState *yyrhs;
|
||||||
return yyr2[yyrule];
|
int yyn;
|
||||||
|
for (yyrhs = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule);
|
||||||
|
yyn > 0;
|
||||||
|
yyrhs = yyrhs->yypred, yyn -= 1)
|
||||||
|
yydestroyGLRState (yymsg, yyrhs);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Left-hand-side symbol for rule #RULE. */
|
/** Left-hand-side symbol for rule #RULE. */
|
||||||
@@ -2001,7 +2012,7 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]b4_location_if([[ yystack->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
|
]b4_location_if([[ yystack->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
|
||||||
yydestroyStackItem ("Error: popping", yys);
|
yydestroyGLRState ("Error: popping", yys);
|
||||||
yystack->yytops.yystates[0] = yys->yypred;
|
yystack->yytops.yystates[0] = yys->yypred;
|
||||||
yystack->yynextFree -= 1;
|
yystack->yynextFree -= 1;
|
||||||
yystack->yyspaceLeft += 1;
|
yystack->yyspaceLeft += 1;
|
||||||
@@ -2201,7 +2212,7 @@ b4_syncline([@oline@], [@ofile@])])dnl
|
|||||||
{
|
{
|
||||||
yyGLRState *yys = yystates[0];
|
yyGLRState *yys = yystates[0];
|
||||||
]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]]
|
]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]]
|
||||||
)[ yydestroyStackItem ("Cleanup: popping", yys);
|
)[ yydestroyGLRState ("Cleanup: popping", yys);
|
||||||
yystates[0] = yys->yypred;
|
yystates[0] = yys->yypred;
|
||||||
yystack.yynextFree -= 1;
|
yystack.yynextFree -= 1;
|
||||||
yystack.yyspaceLeft += 1;
|
yystack.yyspaceLeft += 1;
|
||||||
|
|||||||
@@ -406,7 +406,7 @@ merge (YYSTYPE s1, YYSTYPE s2)
|
|||||||
static void
|
static void
|
||||||
yyerror (char const *msg)
|
yyerror (char const *msg)
|
||||||
{
|
{
|
||||||
printf ("%s\n", msg);
|
fprintf (stderr, "%s\n", msg);
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
|
||||||
@@ -422,11 +422,11 @@ AT_CHECK([[./glr-regr4]], 0,
|
|||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
## ---------------------------------------------------------------------- ##
|
## ------------------------------------------------------------------------- ##
|
||||||
## User destructor for unresolved GLR semantic value ##
|
## User destructor for unresolved GLR semantic value ##
|
||||||
## Thanks to Joel E. Denny for this test; see ##
|
## Thanks to Joel E. Denny for this test; see ##
|
||||||
## <http://lists.gnu.org/archive/html/help-bison/2005-07/msg00013.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])
|
||||||
|
|
||||||
@@ -470,7 +470,7 @@ yylex (void)
|
|||||||
static void
|
static void
|
||||||
yyerror (char const *msg)
|
yyerror (char const *msg)
|
||||||
{
|
{
|
||||||
printf ("%s\n", msg);
|
fprintf (stderr, "%s\n", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -485,7 +485,71 @@ AT_CHECK([[bison -o glr-regr5.c glr-regr5.y]], 0, [],
|
|||||||
])
|
])
|
||||||
AT_COMPILE([glr-regr5])
|
AT_COMPILE([glr-regr5])
|
||||||
|
|
||||||
AT_CHECK([[./glr-regr5]], 0,
|
AT_CHECK([[./glr-regr5]], 0, [],
|
||||||
|
[syntax is ambiguous
|
||||||
|
])
|
||||||
|
|
||||||
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
|
## ------------------------------------------------------------------------- ##
|
||||||
|
## User destructor after an error during a split parse ##
|
||||||
|
## Thanks to Joel E. Denny for this test; see ##
|
||||||
|
## <http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00029.html>. ##
|
||||||
|
## ------------------------------------------------------------------------- ##
|
||||||
|
|
||||||
|
AT_SETUP([User destructor after an error during a split parse])
|
||||||
|
|
||||||
|
AT_DATA_GRAMMAR([glr-regr6.y],
|
||||||
|
[[%{
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
static void yyerror (char const *);
|
||||||
|
static int yylex (void);
|
||||||
|
%}
|
||||||
|
|
||||||
|
%glr-parser
|
||||||
|
%union { int value; }
|
||||||
|
%type <value> 'a'
|
||||||
|
|
||||||
|
%destructor {
|
||||||
|
printf ("Destructor called.\n");
|
||||||
|
} 'a'
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
start: 'a' | 'a' ;
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
static int
|
||||||
|
yylex (void)
|
||||||
|
{
|
||||||
|
static char const *input = "a";
|
||||||
|
return *input++;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
yyerror (char const *msg)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s\n", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
return yyparse () != 1;
|
||||||
|
}
|
||||||
|
]])
|
||||||
|
|
||||||
|
AT_CHECK([[bison -o glr-regr6.c glr-regr6.y]], 0, [],
|
||||||
|
[glr-regr6.y: conflicts: 1 reduce/reduce
|
||||||
|
])
|
||||||
|
AT_COMPILE([glr-regr6])
|
||||||
|
|
||||||
|
AT_CHECK([[./glr-regr6]], 0,
|
||||||
|
[Destructor called.
|
||||||
|
],
|
||||||
[syntax is ambiguous
|
[syntax is ambiguous
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user