167 |
#include <stdlib.h> |
#include <stdlib.h> |
168 |
#include <assert.h> |
#include <assert.h> |
169 |
|
|
170 |
#define YYERROR_VERBOSE 1 |
static int yylex (void); |
171 |
#define YYDEBUG 1 |
static void yyerror (const char *msg); |
172 |
%} |
%} |
173 |
|
%error-verbose |
174 |
|
%debug |
175 |
%verbose |
%verbose |
176 |
|
%locations |
177 |
%union |
%union |
178 |
{ |
{ |
179 |
int ival; |
int ival; |
184 |
input line thing 'x' |
input line thing 'x' |
185 |
|
|
186 |
%destructor |
%destructor |
187 |
{ |
{ fprintf (stdout, "Freeing nterm input (%d from %d)\n", $$, @$.first_line); } |
188 |
fprintf (stdout, "Freeing "); |
input |
|
/* 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' |
|
189 |
|
|
190 |
%{ |
%destructor |
191 |
static int yylex (void); |
{ fprintf (stdout, "Freeing nterm line (%d from %d)\n", $$, @$.first_line); } |
192 |
static void yyerror (const char *msg); |
line |
193 |
%} |
|
194 |
|
%destructor |
195 |
|
{ fprintf (stdout, "Freeing nterm thing (%d from %d)\n", $$, @$.first_line); } |
196 |
|
thing |
197 |
|
|
198 |
|
%destructor |
199 |
|
{ fprintf (stdout, "Freeing token 'x' (%d from %d)\n", $$, @$.first_line); } |
200 |
|
'x' |
201 |
|
|
202 |
%% |
%% |
203 |
input: |
input: |
298 |
} |
} |
299 |
]]) |
]]) |
300 |
|
|
301 |
AT_CHECK([bison --location -d -v -o input.c input.y]) |
AT_CHECK([bison -o input.c input.y]) |
302 |
AT_COMPILE([input]) |
AT_COMPILE([input]) |
303 |
AT_PARSER_CHECK([./input], 1, |
AT_PARSER_CHECK([./input], 1, |
304 |
[[sending: 'x' (value = 0, line 0) |
[[sending: 'x' (value = 0, line 0) |