]> git.saurik.com Git - bison.git/blobdiff - tests/torture.at
tests: handle locations in a more generic way.
[bison.git] / tests / torture.at
index 47435cbcbc6dae69ced8fc4e9236d7b7343440bd..a8837b2246713777c3c61da329df97ee86b40f9f 100644 (file)
@@ -1,5 +1,6 @@
 # Torturing Bison.                                    -*- Autotest -*-
-# Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 Free Software
+
+# Copyright (C) 2001-2002, 2004-2007, 2009-2012 Free Software
 # Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
@@ -41,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;
@@ -54,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
 {
@@ -94,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)
     {
@@ -111,13 +114,6 @@ yylex (void)
     }
   return inner++;
 }
-
-static void
-yyerror (const char *msg)
-{
-  fprintf (stderr, "%s\\n", msg);
-}
-
 int
 main (void)
 {
@@ -126,6 +122,7 @@ main (void)
 }
 EOF
 ]])
+AT_BISON_OPTION_POPDEFS
 
 AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
 mv stdout $1
@@ -156,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;
@@ -169,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
@@ -192,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)
 {
@@ -222,6 +215,7 @@ EOF
 
 AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
 mv stdout $1
+AT_BISON_OPTION_POPDEFS
 ])
 
 
@@ -262,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;
@@ -276,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
 {
@@ -323,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;
     }
@@ -345,12 +341,6 @@ yylex (void)
   return counter++;
 }
 
-static void
-yyerror (const char *msg)
-{
-  fprintf (stderr, "%s\\n", msg);
-}
-
 int
 main (void)
 {
@@ -362,6 +352,7 @@ EOF
 
 AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
 mv stdout $1
+AT_BISON_OPTION_POPDEFS
 ])
 
 
@@ -389,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],
 [[%{
@@ -398,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
@@ -408,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)
 {
@@ -461,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])
 ])