/[bison]/bison/tests/actions.at
ViewVC logotype

Diff of /bison/tests/actions.at

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by akim, Tue Nov 12 09:07:38 2002 UTC revision 1.19 by akim, Tue Nov 12 10:18:05 2002 UTC
# Line 187  static void yyerror (const char *msg); Line 187  static void yyerror (const char *msg);
187  }  }
188  %type <ival> 'x' thing line input  %type <ival> 'x' thing line input
189    
190  %printer { fprintf (yyout, "%d from %d", $$, @$.first_line); }  %printer { fprintf (yyout, "%d@%d", $$, @$.first_line); }
191     input line thing 'x'     input line thing 'x'
192    
193  %destructor  %destructor
194    { fprintf (stdout, "Freeing nterm input (%d from %d)\n", $$, @$.first_line); }    { fprintf (stdout, "Freeing nterm input (%d@%d)\n", $$, @$.first_line); }
195    input    input
196    
197  %destructor  %destructor
198    { fprintf (stdout, "Freeing nterm line (%d from %d)\n", $$, @$.first_line); }    { fprintf (stdout, "Freeing nterm line (%d@%d)\n", $$, @$.first_line); }
199    line    line
200    
201  %destructor  %destructor
202    { fprintf (stdout, "Freeing nterm thing (%d from %d)\n", $$, @$.first_line); }    { fprintf (stdout, "Freeing nterm thing (%d@%d)\n", $$, @$.first_line); }
203    thing    thing
204    
205  %destructor  %destructor
206    { fprintf (stdout, "Freeing token 'x' (%d from %d)\n", $$, @$.first_line); }    { fprintf (stdout, "Freeing token 'x' (%d@%d)\n", $$, @$.first_line); }
207    'x'    'x'
208    
209  %%  %%
# Line 211  input: Line 211  input:
211    /* Nothing. */    /* Nothing. */
212      {      {
213        $$ = 0;        $$ = 0;
214        printf ("input(%d): /* Nothing */';'\n", $$);        printf ("input(%d@%d): /* Nothing */';'\n", $$, @$.first_line);
215      }      }
216  | line input /* Right recursive to load the stack so that popping at  | line input /* Right recursive to load the stack so that popping at
217                  EOF can be exercised.  */                  EOF can be exercised.  */
218      {      {
219        $$ = 2;        $$ = 2;
220        printf ("input(%d): line(%d) input(%d)';'\n", $$, $1, $2);        printf ("input(%d@%d): line(%d@%d) input(%d@%d)';'\n",
221                  $$, @$.first_line, $1, @1.first_line, $2, @2.first_line);
222      }      }
223  ;  ;
224    
# Line 225  line: Line 226  line:
226    thing thing thing ';'    thing thing thing ';'
227      {      {
228        $$ = $1;        $$ = $1;
229        printf ("line(%d): thing(%d) thing(%d) thing(%d) ';'\n", $$, $1, $2, $3);        printf ("line(%d@%d): thing(%d@%d) thing(%d@%d) thing(%d@%d) ';'\n",
230                  $$, @$.first_line, $1, @1.first_line, $2, @2.first_line,
231                  $3, @3.first_line);
232      }      }
233  | thing thing ';'  | thing thing ';'
234      {      {
235        $$ = $1;        $$ = $1;
236        printf ("line(%d): thing(%d) thing(%d) ';'\n", $$, $1, $2);        printf ("line(%d@%d): thing(%d@%d) thing(%d@%d) ';'\n",
237                  $$, @$.first_line, $1, @1.first_line, $2, @2.first_line);
238      }      }
239  | thing ';'  | thing ';'
240      {      {
241        $$ = $1;        $$ = $1;
242        printf ("line(%d): thing(%d) ';'\n", $$, $1);        printf ("line(%d@%d): thing(%d@%d) ';'\n",
243                  $$, @$.first_line, $1, @1.first_line);
244      }      }
245  | error ';'  | error ';'
246      {      {
247        $$ = -1;        $$ = -1;
248        printf ("line(%d): error ';'\n", $$);        printf ("line(%d@%d): error(@%d) ';'\n",
249                  $$, @$.first_line, @1.first_line);
250      }      }
251  ;  ;
252    
# Line 248  thing: Line 254  thing:
254    'x'    'x'
255      {      {
256        $$ = $1;        $$ = $1;
257        printf ("thing(%d): 'x'(%d)\n", $$, $1);        printf ("thing(%d@%d): 'x'(%d@%d)\n",
258                  $$, @$.first_line, $1, @1.first_line);
259      }      }
260  ;  ;
261  %%  %%
# Line 309  AT_CHECK([bison -o input.c input.y]) Line 316  AT_CHECK([bison -o input.c input.y])
316  AT_COMPILE([input])  AT_COMPILE([input])
317  AT_PARSER_CHECK([./input], 1,  AT_PARSER_CHECK([./input], 1,
318  [[sending: 'x' (value = 0, line 0)  [[sending: 'x' (value = 0, line 0)
319  thing(0): 'x'(0)  thing(0@0): 'x'(0@0)
320  sending: 'x' (value = 1, line 10)  sending: 'x' (value = 1, line 10)
321  thing(1): 'x'(1)  thing(1@10): 'x'(1@10)
322  sending: 'x' (value = 2, line 20)  sending: 'x' (value = 2, line 20)
323  thing(2): 'x'(2)  thing(2@20): 'x'(2@20)
324  sending: 'x' (value = 3, line 30)  sending: 'x' (value = 3, line 30)
325  30: parse error, unexpected 'x', expecting ';'  30: parse error, unexpected 'x', expecting ';'
326  Freeing nterm thing (2 from 20)  Freeing nterm thing (2@20)
327  Freeing nterm thing (1 from 10)  Freeing nterm thing (1@10)
328  Freeing nterm thing (0 from 0)  Freeing nterm thing (0@0)
329  Freeing token 'x' (3 from 30)  Freeing token 'x' (3@30)
330  sending: 'x' (value = 4, line 40)  sending: 'x' (value = 4, line 40)
331  Freeing token 'x' (4 from 40)  Freeing token 'x' (4@40)
332  sending: 'x' (value = 5, line 50)  sending: 'x' (value = 5, line 50)
333  Freeing token 'x' (5 from 50)  Freeing token 'x' (5@50)
334  sending: ';' (value = 6, line 60)  sending: ';' (value = 6, line 60)
335  line(-1): error ';'  line(-1@50): error(@50) ';'
336  sending: 'x' (value = 7, line 70)  sending: 'x' (value = 7, line 70)
337  thing(7): 'x'(7)  thing(7@70): 'x'(7@70)
338  sending: 'x' (value = 8, line 80)  sending: 'x' (value = 8, line 80)
339  thing(8): 'x'(8)  thing(8@80): 'x'(8@80)
340  sending: ';' (value = 9, line 90)  sending: ';' (value = 9, line 90)
341  line(7): thing(7) thing(8) ';'  line(7@70): thing(7@70) thing(8@80) ';'
342  sending: 'x' (value = 10, line 100)  sending: 'x' (value = 10, line 100)
343  thing(10): 'x'(10)  thing(10@100): 'x'(10@100)
344  sending: ';' (value = 11, line 110)  sending: ';' (value = 11, line 110)
345  line(10): thing(10) ';'  line(10@100): thing(10@100) ';'
346  sending: 'y' (value = 12, line 120)  sending: 'y' (value = 12, line 120)
347  120: parse error, unexpected $undefined, expecting $end or 'x'  120: parse error, unexpected $undefined, expecting $end or 'x'
348  sending: EOF  sending: EOF
349  Freeing nterm line (10 from 100)  Freeing nterm line (10@100)
350  Freeing nterm line (7 from 70)  Freeing nterm line (7@70)
351  Freeing nterm line (-1 from 50)  Freeing nterm line (-1@50)
352  Parsing FAILED.  Parsing FAILED.
353  ]])  ]])
354    

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26