* data/glr.c (yyprocessOneStack): Synchronize the shift for all

stacks, and iterate another stack in order to call user
destructors.
* tests/glr-regression.at (No users destructors if stack 0 deleted):
New test case.
(Duplicated user destructor for lookahead): This test now is expected
to succeed.
This commit is contained in:
Paul Eggert
2005-12-06 19:38:25 +00:00
parent 32b5b719e4
commit 69ce078b8c
3 changed files with 188 additions and 54 deletions

View File

@@ -633,8 +633,6 @@ AT_CHECK([[./glr-regr7]], 2, [],
[memory exhausted
])
AT_XFAIL_IF(:)
AT_CLEANUP
@@ -667,9 +665,9 @@ AT_DATA_GRAMMAR([glr-regr8.y],
PortClause : T_PORT InterfaceDeclaration T_PORT
{ printf("%d/%d - %d/%d - %d/%d\n",
@1.first_column, @1.last_column,
@2.first_column, @2.last_column,
{ printf("%d/%d - %d/%d - %d/%d\n",
@1.first_column, @1.last_column,
@2.first_column, @2.last_column,
@3.first_column, @3.last_column); }
;
@@ -695,7 +693,7 @@ void yyerror(const char *msg)
static int lexIndex;
int yylex()
int yylex (void)
{
lexIndex += 1;
switch (lexIndex)
@@ -714,7 +712,7 @@ int yylex()
}
int
main (void)
main (void)
{
yyparse();
return 0;
@@ -726,10 +724,91 @@ AT_CHECK([[bison -o glr-regr8.c glr-regr8.y]], 0, [],
])
AT_COMPILE([glr-regr8])
AT_CHECK([[./glr-regr8]], 0,
AT_CHECK([[./glr-regr8]], 0,
[empty: 9/9
1/9 - 9/9 - 13/17
],
[])
AT_CLEANUP
## ------------------------------------------------------------------------- ##
## No users destructors if stack 0 deleted ##
## Thanks to Joel E. Denny for this test; see ##
## <http://lists.gnu.org/archive/html/bison-patches/2005-09/msg00109.html>. ##
## ------------------------------------------------------------------------- ##
AT_SETUP([No users destructors if stack 0 deleted])
AT_DATA_GRAMMAR([glr-regr9.y],
[[
%{
#include <stdio.h>
#include <stdlib.h>
static void yyerror (char const *);
static int yylex (void);
#define YYSTACKEXPANDABLE 0
static int tokens = 0;
static int destructors = 0;
%}
%glr-parser
%union { int dummy; }
%type <dummy> 'a'
%destructor {
destructors += 1;
} 'a'
%%
start:
ambig0 'a' { destructors += 2; }
| ambig1 start { destructors += 1; }
| ambig2 start { destructors += 1; }
;
ambig0: 'a' ;
ambig1: 'a' ;
ambig2: 'a' ;
%%
static int
yylex (void)
{
tokens += 1;
return 'a';
}
static void
yyerror (char const *msg)
{
fprintf (stderr, "%s\n", msg);
}
int
main (void)
{
int exit_status;
exit_status = yyparse ();
if (tokens != destructors)
{
fprintf (stderr, "Tokens = %d, Destructors = %d\n", tokens, destructors);
return 1;
}
return !exit_status;
}
]])
AT_CHECK([[bison -o glr-regr9.c glr-regr9.y]], 0, [],
[glr-regr9.y: conflicts: 1 reduce/reduce
])
AT_COMPILE([glr-regr9])
AT_CHECK([[./glr-regr9]], 0, [],
[memory exhausted
])
AT_CLEANUP