X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/9874f80b2e813a8ad8e5562dbbaa30ecafd5e7d8..9bcffa0c13d1abee13433f14cdb785cbb960425c:/tests/named-refs.at?ds=sidebyside
diff --git a/tests/named-refs.at b/tests/named-refs.at
index c3721c03..3ccf1f66 100644
--- a/tests/named-refs.at
+++ b/tests/named-refs.at
@@ -15,13 +15,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+# FIXME: Duplication with calc.at.
AT_BANNER([[Named references tests.]])
AT_SETUP([Tutorial calculator])
-
+AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([test.y],
[[
%{
+#include
#include
#include
#include
@@ -31,8 +33,8 @@ FILE *input;
static semantic_value global_result = 0;
static int global_count = 0;
static int power (int base, int exponent);
-static void yyerror (const char *s);
-int yylex (void);
+]AT_YYERROR_DECLARE[
+]AT_YYLEX_DECLARE[
%}
%union
@@ -81,12 +83,7 @@ exp:
| '-' error { $$ = 0; YYERROR; }
;
%%
-
-static void yyerror (const char *s)
-{
- fprintf (stderr, "%s\n", s);
-}
-
+]AT_YYERROR_DEFINE[
static int get_char (void)
{
int res = getc (input);
@@ -117,7 +114,8 @@ static int read_signed_integer (void)
return sign * n;
}
-int yylex (void)
+static int
+yylex (void)
{
int c;
/* Skip white space. */
@@ -142,8 +140,7 @@ int yylex (void)
static int power (int base, int exponent)
{
int res = 1;
- if (exponent < 0)
- exit (3);
+ assert (0 <= exponent);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
@@ -165,10 +162,8 @@ int main (int argc, const char **argv)
}
status = yyparse ();
fclose (input);
- if (global_result != result)
- abort ();
- if (global_count != count)
- abort ();
+ assert (global_result == result);
+ assert (global_count == count);
return status;
}
]])
@@ -189,6 +184,7 @@ AT_DATA([input.txt],
AT_BISON_CHECK([-o test.c test.y])
AT_COMPILE([[test]])
AT_PARSER_CHECK([./test input.txt], 0, [], [stderr])
+AT_BISON_OPTION_POPDEFS
AT_CLEANUP
@@ -197,13 +193,13 @@ AT_CLEANUP
AT_SETUP([Undefined and ambiguous references])
-
+AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([test.y],
[[
%{
static int power (int base, int exponent);
-static void yyerror (const char *s);
-int yylex (void);
+]AT_YYERROR_DECLARE[
+]AT_YYLEX_DECLARE[
%}
%union
@@ -267,6 +263,7 @@ test.y:55.3-53: symbol not found in production: r12
test.y:56.29-33: invalid reference: '$expo'
test.y:56.3-46: symbol not found in production: expo
]])
+AT_BISON_OPTION_POPDEFS
AT_CLEANUP
#######################################################################