]> git.saurik.com Git - bison.git/blobdiff - data/push.c
Instead of having skeletons declare all valid %define variables and
[bison.git] / data / push.c
index 3da3f72e69c3cd724be0f2fb291b2a33b7a5dbbb..1482d47149f756d58d9c6e63d6071a42d35c9885 100644 (file)
@@ -1,9 +1,9 @@
-m4_divert(-1)                                                -*- C -*-
+                                                             -*- C -*-
 
 # Yacc compatible skeleton for Bison
 
-# Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
-# Free Software Foundation, Inc.
+# Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+# 2007 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,6 +20,18 @@ m4_divert(-1)                                                -*- C -*-
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301  USA
 
+# Handle BISON_USE_PUSH_FOR_PULL for the test suite.  So that push parsing
+# tests function as written, don't let BISON_USE_PUSH_FOR_PULL modify Bison's
+# behavior at all when push parsing is already requested.
+b4_use_push_for_pull_if([
+  b4_push_if([
+    m4_define([b4_use_push_for_pull_flag], [[0]])
+    b4_define_flag_if([use_push_for_pull])
+  ], [
+    m4_define([b4_push_flag], [[1]])
+    b4_define_flag_if([push])
+  ])])
+
 m4_include(b4_pkgdatadir/[c.m4])
 
 ## ---------------- ##
@@ -132,8 +144,8 @@ m4_define([b4_rhs_location],
 
 # We do want M4 expansion after # for CPP macros.
 m4_changecom()
-m4_divert(0)dnl
-@output b4_parser_file_name
+m4_divert_push(0)dnl
+@output(b4_parser_file_name@)
 b4_copyright([Skeleton implementation for Bison's Yacc-like parsers in C],dnl '
   [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006])[
 
@@ -148,6 +160,7 @@ b4_copyright([Skeleton implementation for Bison's Yacc-like parsers in C],dnl '
    USER NAME SPACE" below.  */
 
 ]b4_identification
+b4_get_percent_code([[top]])[]dnl
 m4_if(b4_prefix, [yy], [],
 [[/* Substitute the variable and function names.  */
 ]b4_pull_if([[#define yyparse         ]b4_prefix[parse
@@ -185,9 +198,7 @@ m4_if(b4_prefix, [yy], [],
 # define YYTOKEN_TABLE ]b4_token_table[
 #endif
 
-]m4_ifdef([b4_requires],
-[[/* Copy the %requires blocks.  */
-]b4_user_requires])[]dnl
+]b4_get_percent_code([[requires]])[]dnl
 
 b4_token_enums_defines(b4_tokens)[
 
@@ -238,14 +249,13 @@ b4_c_function_decl([[yypstate_delete]], [[void]],
                    [[[yypstate *yyps]], [[yyps]]])[
 #endif
 ]])
-m4_ifdef([b4_provides],
-[[/* Copy the %provides blocks.  */
-]b4_user_provides])[]dnl
+b4_get_percent_code([[provides]])[]dnl
 
 [/* Copy the second part of user declarations.  */
-]b4_user_post_prologue[
+]b4_user_post_prologue
+b4_get_percent_code[]dnl
 
-#ifdef short
+[#ifdef short
 # undef short
 #endif
 
@@ -1317,8 +1327,9 @@ yybackup:
     {
 ]b4_push_if([[      if (!yyps->yynew)
         {
-          YYDPRINTF ((stderr, "Return for a new token:\n"));
-          yyresult = YYPUSH_MORE;
+]b4_use_push_for_pull_if([],
+[[          YYDPRINTF ((stderr, "Return for a new token:\n"));
+]])[          yyresult = YYPUSH_MORE;
           goto yypushreturn;
         }
       yyps->yynew = 0;
@@ -1624,24 +1635,25 @@ yyreturn:
   if (yyss != yyssa)
     YYSTACK_FREE (yyss);
 #endif
-]b4_push_if([yypushreturn:])[
-#if YYERROR_VERBOSE
+]b4_push_if([[  yyps->yynew = 1;
+
+yypushreturn:
+]])[#if YYERROR_VERBOSE
   if (yymsg != yymsgbuf)
     YYSTACK_FREE (yymsg);
 #endif
   /* Make sure YYID is used.  */
   return YYID (yyresult);
-]}
+}
+
 
-b4_epilogue
+]b4_epilogue
 b4_defines_if(
-[@output b4_spec_defines_file
+[@output(b4_spec_defines_file@)
 b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl '
   [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006])
 
-m4_ifdef([b4_requires],
-[[/* Copy the %requires blocks.  */
-]b4_user_requires])[]dnl
+b4_get_percent_code([[requires]])[]dnl
 
 b4_token_enums_defines(b4_tokens)
 
@@ -1698,7 +1710,6 @@ b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
                    [[b4_prefix[pstate *yyps]], [[yyps]]])[
 #endif
 ]])
-m4_ifdef([b4_provides],
-[[/* Copy the %provides blocks.  */
-]b4_user_provides])[]
+b4_get_percent_code([[provides]])[]dnl
 ])dnl b4_defines_if
+m4_divert_pop(0)