# _AT_UNUSED_VALUES_DECLARATIONS()
-# --------------------------------------------
+# --------------------------------
# Generate the token, type, and destructor
# declarations for the unused values tests.
AT_SETUP([Torturing the Scanner])
-
+AT_BISON_OPTION_PUSHDEFS
AT_DATA([input.y], [])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:1.1: syntax error, unexpected end of file
#include <stdio.h>
#include <stdlib.h>
+#include <assert.h>
%}
/* %{ and %} can be here too. */
%}
%{
-static void yyerror (const char *s);
-static int yylex (void);
+]AT_YYERROR_DECLARE[
+]AT_YYLEX_DECLARE[
%}
%type <ival> '@<:@'
res.ival = val;
return res;
}
-
+]AT_YYERROR_DEFINE[
static int
yylex (void)
{
#output "; /* "
*/
static size_t toknum;
- if (! (toknum < sizeof input))
- abort ();
+ assert (toknum < sizeof input);
yylval = value_as_yystype (input[toknum]);
return input[toknum++];
}
-
-static void
-yyerror (const char *msg)
-{
- fprintf (stderr, "%s\n", msg);
-}
]])
-# Pacify Emacs'font-lock-mode: "
+# Pacify Emacs' font-lock-mode: "
AT_DATA([main.c],
[[typedef int value;
return yyparse ();
}
]])
+AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-d -v -o input.c input.y])
-AT_COMPILE([input.o], [-c input.c])
-AT_COMPILE([main.o], [-c main.c])
+AT_COMPILE([input.o])
+AT_COMPILE([main.o])
AT_COMPILE([input], [input.o main.o])
AT_PARSER_CHECK([./input], 0,
[[[@<:@],
AT_SETUP([Symbols])
+AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[[%token WITH-DASH
%token WITHOUT_DASH "WITHOUT-DASH"
%token WITH.PERIOD
%token WITHOUT_PERIOD "WITHOUT.PERIOD"
%code {
- void yyerror (char const *);
- int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
}
%%
start: with-dash without_dash with.period without_period;
with.period: WITH.PERIOD;
without_period: "WITHOUT.PERIOD";
%%
+]AT_YYERROR_DEFINE[
+]AT_YYLEX_DEFINE[
]])
+AT_BISON_OPTION_POPDEFS
# POSIX Yacc accept periods, but not dashes.
AT_BISON_CHECK([--yacc input.y], [1], [],
AT_BISON_CHECK([-o input.c input.y])
# Make sure we don't export silly token identifiers with periods or dashes.
-AT_COMPILE([input.o], [-c input.c])
+AT_COMPILE([input.o])
# Periods are genuine letters, they can start identifiers.
AT_BISON_CHECK([[-Werror,no-all,yacc input.y]], [[1]], [[]], [[experr]])
AT_CLEANUP
+
+
+## ------------------------------------------------------ ##
+## %name-prefix and %define api.prefix are incompatible. ##
+## ------------------------------------------------------ ##
+
+AT_SETUP([[%name-prefix and %define api.prefix are incompatible]])
+
+# AT_TEST(DIRECTIVES, OPTIONS, ERROR-LOCATION)
+# --------------------------------------------
+m4_pushdef([AT_TEST],
+[AT_DATA([[input.y]],
+[[$1
+%%
+exp:;
+]])
+AT_BISON_CHECK([[$2 input.y]], [[1]], [[]],
+[[$3: '%name-prefix' and '%define api.prefix' cannot be used together
+]])
+])
+
+AT_TEST([%define api.prefix foo %name-prefix "bar"], [], [input.y:1.9-18])
+AT_TEST([], [-Dapi.prefix=foo -p bar], [<command line>:2])
+AT_TEST([%name-prefix "bar"], [-Dapi.prefix=foo], [<command line>:2])
+AT_TEST([%define api.prefix foo], [-p bar], [input.y:1.9-18])
+
+m4_popdef([AT_TEST])
+
+AT_CLEANUP