]> git.saurik.com Git - bison.git/blobdiff - tests/actions.at
* data/c.m4 (b4_yydestruct_generate, b4_yysymprint_generate): Pass
[bison.git] / tests / actions.at
index cad6b25519a47d8c0f1d09a7680bcd38ab9fb14a..3b4d05d5cbb387a8c3d5749141006beda112d236 100644 (file)
@@ -13,8 +13,8 @@
 
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
 
 AT_BANNER([[User Actions.]])
 
@@ -187,6 +187,7 @@ m4_ifval([$6], [%union
 {
   int ival;
 }])
+AT_LALR1_CC_IF([%define "global_tokens_and_yystype"])
 [
 %{
 ]AT_LALR1_CC_IF([typedef yy::location YYLTYPE;
@@ -286,7 +287,7 @@ thing:
 ;
 %%
 /* Alias to ARGV[1]. */
-const char *yysource = 0;
+const char *source = 0;
 
 static int
 yylex (]AT_LEX_FORMALS[)
@@ -303,12 +304,12 @@ yylex (]AT_LEX_FORMALS[)
   AT_LOC.last_line = AT_LOC.last_column = AT_LOC.first_line + 9;
 ])[
 
-  if (yysource[c])
-    printf ("sending: '%c'", yysource[c]);
+  if (source[c])
+    printf ("sending: '%c'", source[c]);
   else
     printf ("sending: EOF");
   printf (" (%d@%d-%d)\n", c, RANGE (]AT_LOC[));
-  return yysource[c];
+  return source[c];
 }
 
 ]AT_LALR1_CC_IF(
@@ -337,16 +338,18 @@ yyerror (const char *msg)
 int
 main (int argc, const char *argv[])
 {
+  int status;
   yydebug = !!getenv ("YYDEBUG");
   assert (argc == 2);
-  yysource = argv[1];
-  if (yyparse ())
+  source = argv[1];
+  status = yyparse ();
+  switch (status)
     {
-      printf ("Parsing FAILED.\n");
-      exit (1);
+      case 0: printf ("Successful parse.\n"); break;
+      case 1: printf ("Parsing FAILED.\n"); break;
+      default: printf ("Parsing FAILED (status %d).\n", status); break;
     }
-  printf ("Successful parse.\n");
-  return 0;
+  return status;
 }
 ]])
 
@@ -371,6 +374,7 @@ line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
 sending: EOF (3@30-39)
 input (0@29-29): /* Nothing */
 input (2@0-29): line (0@0-29) input (0@29-29)
+Freeing nterm input (2@0-29)
 Successful parse.
 ]])
 
@@ -389,6 +393,7 @@ line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
 sending: EOF (3@30-39)
 input (0@29-29): /* Nothing */
 input (2@0-29): line (-1@0-29) input (0@29-29)
+Freeing nterm input (2@0-29)
 Successful parse.
 ]])
 
@@ -450,7 +455,7 @@ Parsing FAILED.
 # Upon stack overflow, all symbols on the stack should be destroyed.
 # Only check for yacc.c.
 AT_YACC_IF([
-AT_PARSER_CHECK([./input '(x)(x)(x)(x)(x)(x)(x)'], 1,
+AT_PARSER_CHECK([./input '(x)(x)(x)(x)(x)(x)(x)'], 2,
 [[sending: '(' (0@0-9)
 sending: 'x' (1@10-19)
 thing (1@10-19): 'x' (1@10-19)
@@ -485,7 +490,7 @@ sending: '(' (18@180-189)
 sending: 'x' (19@190-199)
 thing (19@190-199): 'x' (19@190-199)
 sending: ')' (20@200-209)
-200-209: parser stack overflow
+200-209: memory exhausted
 Freeing nterm thing (19@190-199)
 Freeing nterm line (15@150-179)
 Freeing nterm line (12@120-149)
@@ -493,7 +498,7 @@ Freeing nterm line (9@90-119)
 Freeing nterm line (6@60-89)
 Freeing nterm line (3@30-59)
 Freeing nterm line (0@0-29)
-Parsing FAILED.
+Parsing FAILED (status 2).
 ]])
 ])