* tests/regression.at (input.y): s/YYEOF/MYEOF/, as the skeleton

defines it.
* data/glr.c (yystos): New.
(b4_yysymprint_generate, b4_yydestruct_generate): Invoke.
(YYDSYMPRINT): New.
(yyval): Don't define it, it is handled via M4.
(yyrecoverParseError): Free verbosely the discarded symbols.
* data/yacc.c (yysymprint): Remove, rather...
(b4_yysymprint_generate): invoke.
* data/c.m4 (b4_yysymprint_generate): New.
Accept pointers as arguments, as opposed to the version from
yacc.c.
(b4_yydestruct_generate): Likewise.
* tests/cations.at (Printers and Destructors): Use Bison directives
instead of CPP macros.
Don't rely on internal details.
This commit is contained in:
Akim Demaille
2002-11-12 09:03:13 +00:00
parent b0400cc6ef
commit 7bd6c77e5e
7 changed files with 156 additions and 77 deletions

View File

@@ -167,10 +167,13 @@ AT_DATA([[input.y]],
#include <stdlib.h>
#include <assert.h>
#define YYERROR_VERBOSE 1
#define YYDEBUG 1
static int yylex (void);
static void yyerror (const char *msg);
%}
%error-verbose
%debug
%verbose
%locations
%union
{
int ival;
@@ -181,20 +184,20 @@ AT_DATA([[input.y]],
input line thing 'x'
%destructor
{
fprintf (stdout, "Freeing ");
/* FIXME: Ouch: INTERNAL DETAILS EXPOSED HERE. */
/* Cannot use $$ which is the union member, not the union itself. */
yysymprint (stdout, yytype, yyvalue, @$);
fprintf (stdout, "\n");
}
input line thing 'x'
{ fprintf (stdout, "Freeing nterm input (%d from %d)\n", $$, @$.first_line); }
input
%{
static int yylex (void);
static void yyerror (const char *msg);
%}
%destructor
{ fprintf (stdout, "Freeing nterm line (%d from %d)\n", $$, @$.first_line); }
line
%destructor
{ fprintf (stdout, "Freeing nterm thing (%d from %d)\n", $$, @$.first_line); }
thing
%destructor
{ fprintf (stdout, "Freeing token 'x' (%d from %d)\n", $$, @$.first_line); }
'x'
%%
input:
@@ -295,7 +298,7 @@ main (void)
}
]])
AT_CHECK([bison --location -d -v -o input.c input.y])
AT_CHECK([bison -o input.c input.y])
AT_COMPILE([input])
AT_PARSER_CHECK([./input], 1,
[[sending: 'x' (value = 0, line 0)

View File

@@ -318,7 +318,7 @@ AT_DATA([input.y],
void yyerror (const char *s);
int yylex (void);
%}
[%token YYEOF 0 "end of file"
[%token MYEOF 0 "end of file"
%token 'a' "a"
%token b "b"
%token c 'c'