]> git.saurik.com Git - bison.git/blobdiff - tests/input.at
style changes in the scanners
[bison.git] / tests / input.at
index 2f667d0ad5c6a6a3adf3b6a9751bb86bf48bcaf7..82d97f53fe49214792db9d1d0e32bca67ce07c77 100644 (file)
@@ -69,7 +69,7 @@ AT_CLEANUP
 
 
 # _AT_UNUSED_VALUES_DECLARATIONS()
-# --------------------------------------------
+# --------------------------------
 # Generate the token, type, and destructor
 # declarations for the unused values tests.
 
@@ -442,6 +442,7 @@ char apostrophe = '\'';
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <assert.h>
 %}
 /* %{ and %} can be here too. */
 
@@ -509,8 +510,7 @@ 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++];
 }
@@ -533,8 +533,8 @@ main (void)
 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,
 [[[@<:@],
@@ -654,7 +654,7 @@ input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash
 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.
@@ -1340,3 +1340,96 @@ input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar
 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
+
+
+## ---------------- ##
+## Code injection.  ##
+## ---------------- ##
+
+
+AT_SETUP([[Code injection]])
+
+m4_pattern_allow([^m4_errprintn$])
+
+# AT_TEST([MACRO])
+# ----------------
+# Try to have MACRO be run by bison.
+m4_pushdef([AT_TEST],
+[AT_DATA([[input.y]],
+[[%type <$1(DEAD %type)> exp
+%token <$1(DEAD %token)> a
+%initial-action
+{
+  $$;
+  $<$1(DEAD %initial-action)>$
+};
+%printer
+{
+  $$
+  $<$1(DEAD %printer)>$
+} <> <*>;
+%lex-param
+{
+  $1(DEAD %lex-param)
+};
+%parse-param
+{
+  $1(DEAD %parse-param)
+};
+%%
+exp:
+  a a[last]
+  {
+    $$;
+    $][1;
+    $<$1(DEAD action 1)>$
+    $<$1(DEAD action 2)>1
+    $<$1(DEAD action 3)>last
+    $<$1(DEAD action 4)>0
+    ;
+  };
+]])
+
+# FIXME: Provide a means to iterate over all the skeletons.
+AT_BISON_CHECK([[-d               input.y]])
+AT_BISON_CHECK([[-d -S glr.c      input.y]])
+AT_BISON_CHECK([[-d -S lalr1.cc   input.y]])
+AT_BISON_CHECK([[-d -S glr.cc     input.y]])
+AT_BISON_CHECK([[   -S lalr1.java input.y]])
+])
+
+AT_TEST([m4_errprintn])
+AT_TEST([@:>@m4_errprintn])
+
+m4_popdef([AT_TEST])
+
+AT_CLEANUP