bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01-strenghten-printer.patch


From: Akim Demaille
Subject: 01-strenghten-printer.patch
Date: Sat, 16 Nov 2002 13:31:16 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        
        Make the ``Printers and Destructors'' test more verbose, taking
        `yacc.c''s behavior as (possibly wrong) reference.
        
        * tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Use printf
        instead of fprint on stdout.
        Set and report the last_line of the symbols.
        Consistently display values and locations.
        
Index: tests/actions.at
--- tests/actions.at Sat, 16 Nov 2002 09:33:15 +0100 akim
+++ tests/actions.at Sat, 16 Nov 2002 10:00:18 +0100 akim
@@ -320,7 +320,7 @@ m4_define([_AT_CHECK_PRINTER_AND_DESTRUC
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
-
+#define RANGE(Location) (Location).first_line, (Location).last_line
 static int yylex (void);
 static void yyerror (const char *msg);
 %}
@@ -334,23 +334,23 @@ m4_define([_AT_CHECK_PRINTER_AND_DESTRUC
 }
 %type <ival> 'x' thing line input
 
-%printer { fprintf (yyout, "address@hidden", $$, @$.first_line); }
+%printer { fprintf (yyout, "address@hidden", $$, RANGE (@$)); }
    input line thing 'x'
 
 %destructor
-  { fprintf (stdout, "Freeing nterm input (address@hidden)\n", $$, 
@$.first_line); }
+  { printf ("Freeing nterm input (address@hidden)\n", $$, RANGE (@$)); }
   input
 
 %destructor
-  { fprintf (stdout, "Freeing nterm line (address@hidden)\n", $$, 
@$.first_line); }
+  { printf ("Freeing nterm line (address@hidden)\n", $$, RANGE (@$)); }
   line
 
 %destructor
-  { fprintf (stdout, "Freeing nterm thing (address@hidden)\n", $$, 
@$.first_line); }
+  { printf ("Freeing nterm thing (address@hidden)\n", $$, RANGE (@$)); }
   thing
 
 %destructor
-  { fprintf (stdout, "Freeing token 'x' (address@hidden)\n", $$, 
@$.first_line); }
+  { printf ("Freeing token 'x' (address@hidden)\n", $$, RANGE (@$)); }
   'x'
 
 %%
@@ -358,14 +358,14 @@ input:
   /* Nothing. */
     {
       $$ = 0;
-      printf ("input(address@hidden): /* Nothing */';'\n", $$, @$.first_line);
+      printf ("input (address@hidden): /* Nothing */';'\n", $$, RANGE (@$));
     }
 | line input /* Right recursive to load the stack so that popping at
                EOF can be exercised.  */
     {
       $$ = 2;
-      printf ("input(address@hidden): line(address@hidden) 
input(address@hidden)';'\n",
-             $$, @$.first_line, $1, @1.first_line, $2, @2.first_line);
+      printf ("input (address@hidden): line (address@hidden) input 
(address@hidden)';'\n",
+             $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
     }
 ;
 
@@ -373,27 +373,27 @@ line:
   thing thing thing ';'
     {
       $$ = $1;
-      printf ("line(address@hidden): thing(address@hidden) 
thing(address@hidden) thing(address@hidden) ';'\n",
-              $$, @$.first_line, $1, @1.first_line, $2, @2.first_line,
-              $3, @3.first_line);
+      printf ("line (address@hidden): thing (address@hidden) thing 
(address@hidden) thing (address@hidden) ';'\n",
+              $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
+              $3, RANGE (@3));
     }
 | thing thing ';'
     {
       $$ = $1;
-      printf ("line(address@hidden): thing(address@hidden) 
thing(address@hidden) ';'\n",
-              $$, @$.first_line, $1, @1.first_line, $2, @2.first_line);
+      printf ("line (address@hidden): thing (address@hidden) thing 
(address@hidden) ';'\n",
+              $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
     }
 | thing ';'
     {
       $$ = $1;
-      printf ("line(address@hidden): thing(address@hidden) ';'\n",
-              $$, @$.first_line, $1, @1.first_line);
+      printf ("line (address@hidden): thing (address@hidden) ';'\n",
+              $$, RANGE (@$), $1, RANGE (@1));
     }
 | error ';'
     {
       $$ = -1;
-      printf ("line(address@hidden): error(@%d) ';'\n",
-              $$, @$.first_line, @1.first_line);
+      printf ("line (address@hidden): error (@%d-%d) ';'\n",
+              $$, RANGE (@$), RANGE (@1));
     }
 ;
 
@@ -401,8 +401,8 @@ thing:
   'x'
     {
       $$ = $1;
-      printf ("thing(address@hidden): 'x'(address@hidden)\n",
-              $$, @$.first_line, $1, @1.first_line);
+      printf ("thing (address@hidden): 'x' (address@hidden)\n",
+              $$, RANGE (@$), $1, RANGE (@1));
     }
 ;
 %%
@@ -411,7 +411,7 @@ thing:
 {
   static const unsigned int input[] =
     {
-      /* Exericise the discarding of stack top and input until `error'
+      /* Exercise the discarding of stack top and input until `error'
          can be reduced.  */
       'x', 'x', 'x', 'x', 'x', 'x', ';',
 
@@ -427,9 +427,10 @@ thing:
     {
        yylval.ival = counter;
        /* As in BASIC, line numbers go from 10 to 10.  */
-       yylloc.first_line = 10 * counter;
-       printf ("sending: '%c' (value = %d, line %d)\n",
-               input[counter], yylval.ival, yylloc.first_line);
+       yylloc.first_line = yylloc.first_column = 10 * counter;
+       yylloc.last_line = yylloc.last_column = yylloc.first_line + 9;
+       printf ("sending: '%c' (address@hidden)\n",
+               input[counter], yylval.ival, RANGE (yylloc));
        return (int) input[counter++];
     }
   else
@@ -442,7 +443,7 @@ thing:
 static void
 yyerror (const char *msg)
 {
-  fprintf (stdout, "%d: %s\n", yylloc.first_line, msg);
+  printf ("%d-%d: %s\n", RANGE (yylloc), msg);
 }
 
 int
@@ -451,10 +452,10 @@ thing:
   yydebug = !!getenv ("YYDEBUG");
   if (yyparse ())
     {
-      fprintf (stdout, "Parsing FAILED.\n");
+      printf ("Parsing FAILED.\n");
       exit (1);
     }
-  fprintf (stdout, "Successful parse.\n");
+  printf ("Successful parse.\n");
   return 0;
 }
 ]])
@@ -462,40 +463,40 @@ thing:
 AT_CHECK([bison -o input.c input.y])
 AT_COMPILE([input])
 AT_PARSER_CHECK([./input], 1,
-[[sending: 'x' (value = 0, line 0)
-thing(address@hidden): 'x'(address@hidden)
-sending: 'x' (value = 1, line 10)
-thing(address@hidden): 'x'(address@hidden)
-sending: 'x' (value = 2, line 20)
-thing(address@hidden): 'x'(address@hidden)
-sending: 'x' (value = 3, line 30)
-30: syntax error, unexpected 'x', expecting ';'
-Freeing nterm thing (address@hidden)
-Freeing nterm thing (address@hidden)
-Freeing nterm thing (address@hidden)
-Freeing token 'x' (address@hidden)
-sending: 'x' (value = 4, line 40)
-Freeing token 'x' (address@hidden)
-sending: 'x' (value = 5, line 50)
-Freeing token 'x' (address@hidden)
-sending: ';' (value = 6, line 60)
-line(address@hidden): error(@50) ';'
-sending: 'x' (value = 7, line 70)
-thing(address@hidden): 'x'(address@hidden)
-sending: 'x' (value = 8, line 80)
-thing(address@hidden): 'x'(address@hidden)
-sending: ';' (value = 9, line 90)
-line(address@hidden): thing(address@hidden) thing(address@hidden) ';'
-sending: 'x' (value = 10, line 100)
-thing(address@hidden): 'x'(address@hidden)
-sending: ';' (value = 11, line 110)
-line(address@hidden): thing(address@hidden) ';'
-sending: 'y' (value = 12, line 120)
-120: syntax error, unexpected $undefined, expecting $end or 'x'
+[[sending: 'x' (address@hidden)
+thing (address@hidden): 'x' (address@hidden)
+sending: 'x' (address@hidden)
+thing (address@hidden): 'x' (address@hidden)
+sending: 'x' (address@hidden)
+thing (address@hidden): 'x' (address@hidden)
+sending: 'x' (address@hidden)
+30-39: syntax error, unexpected 'x', expecting ';'
+Freeing nterm thing (address@hidden)
+Freeing nterm thing (address@hidden)
+Freeing nterm thing (address@hidden)
+Freeing token 'x' (address@hidden)
+sending: 'x' (address@hidden)
+Freeing token 'x' (address@hidden)
+sending: 'x' (address@hidden)
+Freeing token 'x' (address@hidden)
+sending: ';' (address@hidden)
+line (address@hidden): error (@50-59) ';'
+sending: 'x' (address@hidden)
+thing (address@hidden): 'x' (address@hidden)
+sending: 'x' (address@hidden)
+thing (address@hidden): 'x' (address@hidden)
+sending: ';' (address@hidden)
+line (address@hidden): thing (address@hidden) thing (address@hidden) ';'
+sending: 'x' (address@hidden)
+thing (address@hidden): 'x' (address@hidden)
+sending: ';' (address@hidden)
+line (address@hidden): thing (address@hidden) ';'
+sending: 'y' (address@hidden)
+120-129: syntax error, unexpected $undefined, expecting $end or 'x'
 sending: EOF
-Freeing nterm line (address@hidden)
-Freeing nterm line (address@hidden)
-Freeing nterm line (address@hidden)
+Freeing nterm line (address@hidden)
+Freeing nterm line (address@hidden)
+Freeing nterm line (address@hidden)
 Parsing FAILED.
 ]])
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]