]> git.saurik.com Git - bison.git/blobdiff - tests/torture.at
tests: factor.
[bison.git] / tests / torture.at
index 2b2d422729f2cc4b25fbc283665fc40153aa8243..a8837b2246713777c3c61da329df97ee86b40f9f 100644 (file)
@@ -42,7 +42,8 @@ esac])
 # Create FILE-NAME, containing a self checking parser for a huge
 # triangular grammar.
 m4_define([AT_DATA_TRIANGULAR_GRAMMAR],
-[AT_DATA([[gengram.pl]],
+[AT_BISON_OPTION_PUSHDEFS
+AT_DATA([[gengram.pl]],
 [[#! /usr/bin/perl -w
 
 use strict;
@@ -55,9 +56,9 @@ print <<EOF;
 %{
 #include <stdio.h>
 #include <stdlib.h>
-
-static int yylex (void);
-static void yyerror (const char *msg);
+#define MAX $max
+]AT_YYLEX_DECLARE[
+]AT_YYERROR_DECLARE[
 %}
 %union
 {
@@ -95,14 +96,15 @@ for my $size (1 .. $max)
   };
 print ";\n";
 
-print <<EOF;
+print <<\EOF;
 %%
+]AT_YYERROR_DEFINE[
 static int
 yylex (void)
 {
   static int inner = 1;
   static int outer = 0;
-  if (outer > $max)
+  if (outer > MAX)
     return 0;
   else if (inner > outer)
     {
@@ -112,13 +114,6 @@ yylex (void)
     }
   return inner++;
 }
-
-static void
-yyerror (const char *msg)
-{
-  fprintf (stderr, "%s\\n", msg);
-}
-
 int
 main (void)
 {
@@ -127,6 +122,7 @@ main (void)
 }
 EOF
 ]])
+AT_BISON_OPTION_POPDEFS
 
 AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
 mv stdout $1
@@ -157,7 +153,8 @@ AT_CLEANUP
 # Create FILE-NAME, containing a self checking parser for a huge
 # horizontal grammar.
 m4_define([AT_DATA_HORIZONTAL_GRAMMAR],
-[AT_DATA([[gengram.pl]],
+[AT_BISON_OPTION_PUSHDEFS
+AT_DATA([[gengram.pl]],
 [[#! /usr/bin/perl -w
 
 use strict;
@@ -170,9 +167,9 @@ print <<EOF;
 %{
 #include <stdio.h>
 #include <stdlib.h>
-
-static int yylex (void);
-static void yyerror (const char *msg);
+#define MAX $max
+]AT_YYLEX_DECLARE[
+]AT_YYERROR_DECLARE[
 %}
 
 %token
@@ -193,25 +190,20 @@ print
        (map { "\"$_\"" } (1 .. $max)), ";"),
   "\n";
 
-print <<EOF;
+print <<\EOF;
 %%
+]AT_YYERROR_DEFINE[
 static int
 yylex (void)
 {
   static int counter = 1;
-  if (counter <= $max)
+  if (counter <= MAX)
     return counter++;
-  if (counter++ != $max + 1)
+  if (counter++ != MAX + 1)
     abort ();
   return 0;
 }
 
-static void
-yyerror (const char *msg)
-{
-  fprintf (stderr, "%s\\n", msg);
-}
-
 int
 main (void)
 {
@@ -223,6 +215,7 @@ EOF
 
 AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
 mv stdout $1
+AT_BISON_OPTION_POPDEFS
 ])
 
 
@@ -263,7 +256,8 @@ AT_CLEANUP
 # Create FILE-NAME, containing a self checking parser for a grammar
 # requiring SIZE lookahead tokens.
 m4_define([AT_DATA_LOOKAHEAD_TOKENS_GRAMMAR],
-[AT_DATA([[gengram.pl]],
+[AT_BISON_OPTION_PUSHDEFS
+AT_DATA([[gengram.pl]],
 [[#! /usr/bin/perl -w
 
 use strict;
@@ -277,9 +271,9 @@ print <<EOF;
 # include <stdio.h>
 # include <stdlib.h>
 # include <assert.h>
-
-static int yylex (void);
-static void yyerror (const char *msg);
+# define MAX $max
+]AT_YYLEX_DECLARE[
+]AT_YYERROR_DECLARE[
 %}
 %union
 {
@@ -324,16 +318,17 @@ for my $count (1 .. $max)
     print "n$count: token { \$\$ = $count; };\n";
   };
 
-print <<EOF;
+print <<\EOF;
 %%
+]AT_YYERROR_DEFINE[
 static int
 yylex (void)
 {
   static int return_token = 1;
   static int counter = 1;
-  if (counter > $max)
+  if (counter > MAX)
     {
-      if (counter++ != $max + 1)
+      if (counter++ != MAX + 1)
        abort ();
       return 0;
     }
@@ -346,12 +341,6 @@ yylex (void)
   return counter++;
 }
 
-static void
-yyerror (const char *msg)
-{
-  fprintf (stderr, "%s\\n", msg);
-}
-
 int
 main (void)
 {
@@ -363,6 +352,7 @@ EOF
 
 AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
 mv stdout $1
+AT_BISON_OPTION_POPDEFS
 ])
 
 
@@ -390,7 +380,8 @@ AT_CLEANUP
 # ------------------------------------------------
 # A parser specialized in torturing the stack size.
 m4_define([AT_DATA_STACK_TORTURE],
-[# A grammar of parens growing the stack thanks to right recursion.
+[AT_BISON_OPTION_PUSHDEFS([$2])
+# A grammar of parens growing the stack thanks to right recursion.
 # exp:
 AT_DATA([input.y],
 [[%{
@@ -399,8 +390,8 @@ AT_DATA([input.y],
 #include <stdio.h>
 #include <stdlib.h>
 ]$1[
-  static int yylex (void);
-  static void yyerror (const char *msg);
+  ]AT_YYLEX_DECLARE[
+  ]AT_YYERROR_DECLARE[
 %}
 ]$2[
 %error-verbose
@@ -409,12 +400,7 @@ AT_DATA([input.y],
 %%
 exp: WAIT_FOR_EOF exp | ;
 %%
-static void
-yyerror (const char *msg)
-{
-  fprintf (stderr, "%s\n", msg);
-}
-
+]AT_YYERROR_DEFINE[
 static int
 yylex (void)
 {
@@ -462,6 +448,7 @@ main (int argc, const char **argv)
   }
 }
 ]])
+AT_BISON_OPTION_POPDEFS([$2])
 AT_BISON_CHECK([-o input.c input.y])
 AT_COMPILE([input])
 ])