]> git.saurik.com Git - bison.git/blobdiff - tests/actions.at
build: move silent rules.
[bison.git] / tests / actions.at
index 87051cefe16a9192df780b20a76e6819a80eab57..22c3aa25dca58fedc7a14618b97915124d4d355c 100644 (file)
@@ -345,7 +345,7 @@ thing:
 ;
 %%
 /* Alias to ARGV[1]. */
-const char *source = 0;
+const char *source = YY_NULL;
 
 static int
 yylex (]AT_LEX_FORMALS[)
@@ -889,7 +889,7 @@ AT_CLEANUP
 AT_SETUP([Default %printer and %destructor for user-defined end token])
 
 # _AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN(TYPED)
-# -----------------------------------------------------------------------------
+# -------------------------------------------------------------
 m4_define([_AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN],
 [m4_if($1, 0,
   [m4_pushdef([kind], []) m4_pushdef([not_kind], [*])],
@@ -1525,3 +1525,67 @@ AT_PARSER_CHECK([[./input]], [[0]], [],
 ]])
 
 AT_CLEANUP
+
+## ---------- ##
+## YYBACKUP.  ##
+## ---------- ##
+
+AT_SETUP([[YYBACKUP]])
+
+AT_DATA_GRAMMAR([input.y],
+[[
+%error-verbose
+%debug
+%pure-parser
+%code {
+# include <stdio.h>
+# include <stdlib.h>
+# include <assert.h>
+
+  static void yyerror (const char *msg);
+  static int yylex (YYSTYPE *yylval);
+}
+%%
+input:
+  exp exp {}
+;
+
+exp:
+  'a'     { printf ("a: %d\n", $1); }
+| 'b'     { YYBACKUP('a', 123); }
+| 'c' 'd' { YYBACKUP('a', 456); }
+;
+
+%%
+static int
+yylex (YYSTYPE *yylval)
+{
+  static char const input[] = "bcd";
+  static size_t toknum;
+  assert (toknum < sizeof input);
+  *yylval = (toknum + 1) * 10;
+  return input[toknum++];
+}
+
+static void
+yyerror (const char *msg)
+{
+  fprintf (stderr, "%s\n", msg);
+}
+
+int
+main (void)
+{
+  yydebug = !!getenv("YYDEBUG");
+  return yyparse ();
+}
+]])
+
+AT_BISON_CHECK([[-o input.c input.y]])
+AT_COMPILE([[input]])
+AT_PARSER_CHECK([[./input]], [[0]],
+[[a: 123
+a: 456
+]])
+
+AT_CLEANUP