177 |
int ival; |
int ival; |
178 |
} |
} |
179 |
%type <ival> 'x' thing line input |
%type <ival> 'x' thing line input |
180 |
%destructor { printf ("Freeing input %d\n", $$); } input |
%destructor { printf ("Freeing input %d from %d\n", $$, @$.first_line); } input |
181 |
%destructor { printf ("Freeing line %d\n", $$); } line |
%destructor { printf ("Freeing line %d from %d\n", $$, @$.first_line); } line |
182 |
%destructor { printf ("Freeing thing %d\n", $$); } thing |
%destructor { printf ("Freeing thing %d from %d\n", $$, @$.first_line); } thing |
183 |
%destructor { printf ("Freeing 'x' %d\n", $$); } 'x' |
%destructor { printf ("Freeing 'x' %d from %d\n", $$, @$.first_line); } 'x' |
184 |
|
|
185 |
%{ |
%{ |
186 |
static int yylex (void); |
static int yylex (void); |
256 |
{ |
{ |
257 |
yylval.ival = counter; |
yylval.ival = counter; |
258 |
printf ("sending: '%c'(%d)\n", input[counter], counter); |
printf ("sending: '%c'(%d)\n", input[counter], counter); |
259 |
|
/* As in BASIC, line numbers go from 10 to 10. */ |
260 |
|
yylloc.first_line = 10 * counter; |
261 |
return input[counter++]; |
return input[counter++]; |
262 |
} |
} |
263 |
else |
else |
270 |
static void |
static void |
271 |
yyerror (const char *msg) |
yyerror (const char *msg) |
272 |
{ |
{ |
273 |
fprintf (stdout, "%s\n", msg); |
fprintf (stdout, "%d: %s\n", yylloc.first_line, msg); |
274 |
} |
} |
275 |
|
|
276 |
static void |
static void |
293 |
} |
} |
294 |
]]) |
]]) |
295 |
|
|
296 |
AT_CHECK([bison input.y -d -v -o input.c]) |
AT_CHECK([bison input.y --location -d -v -o input.c]) |
297 |
AT_CHECK([$CC $CFLAGS $CPPFLAGS input.c -o input], 0, [], [ignore]) |
AT_CHECK([$CC $CFLAGS $CPPFLAGS input.c -o input], 0, [], [ignore]) |
298 |
AT_CHECK([./input], 1, |
AT_CHECK([./input], 1, |
299 |
[[sending: 'x'(0) |
[[sending: 'x'(0) |
303 |
sending: 'x'(2) |
sending: 'x'(2) |
304 |
thing(2): 'x'(2) |
thing(2): 'x'(2) |
305 |
sending: 'x'(3) |
sending: 'x'(3) |
306 |
parse error, unexpected 'x', expecting ';' |
30: parse error, unexpected 'x', expecting ';' |
307 |
Freeing thing 2 |
Freeing thing 2 from 20 |
308 |
Freeing thing 1 |
Freeing thing 1 from 10 |
309 |
Freeing thing 0 |
Freeing thing 0 from 0 |
310 |
Freeing 'x' 3 |
Freeing 'x' 3 from 30 |
311 |
sending: 'x'(4) |
sending: 'x'(4) |
312 |
Freeing 'x' 4 |
Freeing 'x' 4 from 40 |
313 |
sending: 'x'(5) |
sending: 'x'(5) |
314 |
Freeing 'x' 5 |
Freeing 'x' 5 from 50 |
315 |
sending: ';'(6) |
sending: ';'(6) |
316 |
line(-1): error ';' |
line(-1): error ';' |
317 |
sending: 'x'(7) |
sending: 'x'(7) |
325 |
sending: ';'(11) |
sending: ';'(11) |
326 |
line(10): thing(10) ';' |
line(10): thing(10) ';' |
327 |
sending: 'y'(12) |
sending: 'y'(12) |
328 |
parse error, unexpected $undefined., expecting $ or error or 'x' |
120: parse error, unexpected $undefined., expecting $ or error or 'x' |
329 |
sending: EOF |
sending: EOF |
330 |
Freeing line 10 |
Freeing line 10 from 100 |
331 |
Freeing line 7 |
Freeing line 7 from 70 |
332 |
Freeing line -1 |
Freeing line -1 from 50 |
333 |
Parsing FAILED. |
Parsing FAILED. |
334 |
]]) |
]]) |
335 |
|
|