193 |
%{ |
%{ |
194 |
static int yylex (void); |
static int yylex (void); |
195 |
static void yyerror (const char *msg); |
static void yyerror (const char *msg); |
|
static void yyprint (FILE *out, int num, YYSTYPE val); |
|
196 |
%} |
%} |
197 |
|
|
198 |
|
|
251 |
can be reduced. */ |
can be reduced. */ |
252 |
'x', 'x', 'x', 'x', 'x', 'x', ';', |
'x', 'x', 'x', 'x', 'x', 'x', ';', |
253 |
|
|
254 |
/* Load the stack and provoke an error that cannot be caught be |
/* Load the stack and provoke an error that cannot be caught by |
255 |
the grammar, and check that the stack is cleared. */ |
the grammar, to check that the stack is cleared. */ |
256 |
'x', 'x', ';', |
'x', 'x', ';', |
257 |
'x', ';', |
'x', ';', |
258 |
'y' |
'y' |
259 |
}; |
}; |
260 |
static int counter = 0; |
static unsigned int counter = 0; |
261 |
|
|
262 |
if (counter < (sizeof(input) / sizeof (input[0]))) |
if (counter < (sizeof(input) / sizeof (input[0]))) |
263 |
{ |
{ |
264 |
yylval.ival = counter; |
yylval.ival = counter; |
|
printf ("sending: '%c' (line %d)\n", input[counter], counter); |
|
265 |
/* As in BASIC, line numbers go from 10 to 10. */ |
/* As in BASIC, line numbers go from 10 to 10. */ |
266 |
yylloc.first_line = 10 * counter; |
yylloc.first_line = 10 * counter; |
267 |
return input[counter++]; |
printf ("sending: '%c' (value = %d, line %d)\n", |
268 |
|
input[counter], yylval.ival, yylloc.first_line); |
269 |
|
return (int) input[counter++]; |
270 |
} |
} |
271 |
else |
else |
272 |
{ |
{ |
298 |
AT_CHECK([bison input.y --location -d -v -o input.c]) |
AT_CHECK([bison input.y --location -d -v -o input.c]) |
299 |
AT_CHECK([$CC $CFLAGS $CPPFLAGS input.c -o input], 0, [], [ignore]) |
AT_CHECK([$CC $CFLAGS $CPPFLAGS input.c -o input], 0, [], [ignore]) |
300 |
AT_CHECK([./input], 1, |
AT_CHECK([./input], 1, |
301 |
[[sending: 'x' (line 0) |
[[sending: 'x' (value = 0, line 0) |
302 |
thing(0): 'x'(0) |
thing(0): 'x'(0) |
303 |
sending: 'x' (line 1) |
sending: 'x' (value = 1, line 10) |
304 |
thing(1): 'x'(1) |
thing(1): 'x'(1) |
305 |
sending: 'x' (line 2) |
sending: 'x' (value = 2, line 20) |
306 |
thing(2): 'x'(2) |
thing(2): 'x'(2) |
307 |
sending: 'x' (line 3) |
sending: 'x' (value = 3, line 30) |
308 |
30: parse error, unexpected 'x', expecting ';' |
30: parse error, unexpected 'x', expecting ';' |
309 |
Freeing nterm thing (2 from 20) |
Freeing nterm thing (2 from 20) |
310 |
Freeing nterm thing (1 from 10) |
Freeing nterm thing (1 from 10) |
311 |
Freeing nterm thing (0 from 0) |
Freeing nterm thing (0 from 0) |
312 |
Freeing token 'x' (3 from 30) |
Freeing token 'x' (3 from 30) |
313 |
sending: 'x' (line 4) |
sending: 'x' (value = 4, line 40) |
314 |
Freeing token 'x' (4 from 40) |
Freeing token 'x' (4 from 40) |
315 |
sending: 'x' (line 5) |
sending: 'x' (value = 5, line 50) |
316 |
Freeing token 'x' (5 from 50) |
Freeing token 'x' (5 from 50) |
317 |
sending: ';' (line 6) |
sending: ';' (value = 6, line 60) |
318 |
line(-1): error ';' |
line(-1): error ';' |
319 |
sending: 'x' (line 7) |
sending: 'x' (value = 7, line 70) |
320 |
thing(7): 'x'(7) |
thing(7): 'x'(7) |
321 |
sending: 'x' (line 8) |
sending: 'x' (value = 8, line 80) |
322 |
thing(8): 'x'(8) |
thing(8): 'x'(8) |
323 |
sending: ';' (line 9) |
sending: ';' (value = 9, line 90) |
324 |
line(7): thing(7) thing(8) ';' |
line(7): thing(7) thing(8) ';' |
325 |
sending: 'x' (line 10) |
sending: 'x' (value = 10, line 100) |
326 |
thing(10): 'x'(10) |
thing(10): 'x'(10) |
327 |
sending: ';' (line 11) |
sending: ';' (value = 11, line 110) |
328 |
line(10): thing(10) ';' |
line(10): thing(10) ';' |
329 |
sending: 'y' (line 12) |
sending: 'y' (value = 12, line 120) |
330 |
120: parse error, unexpected $undefined., expecting $ or error or 'x' |
120: parse error, unexpected $undefined., expecting $ or error or 'x' |
331 |
sending: EOF |
sending: EOF |
332 |
Freeing nterm line (10 from 100) |
Freeing nterm line (10 from 100) |