X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/cd9e1ba28d2ee5036db6bf932104d63a3eac76a7..c373bf8bb8da68ed12b1e73aaa2d777f6c701e46:/data/yacc.c diff --git a/data/yacc.c b/data/yacc.c index e297c643..4461f023 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -1,24 +1,26 @@ -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 +# 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 -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. - +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. - +# # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301 USA +# along with this program. If not, see . + +# This hack will go away when we mv push.c yacc.c. +m4_ifndef([b4_percent_define(api.push_pull)], +[m4_if(b4_use_push_for_pull_flag, [0], [ m4_include(b4_pkgdatadir/[c.m4]) @@ -133,8 +135,8 @@ m4_define([b4_rhs_location], # We do want M4 expansion after # for CPP macros. m4_changecom() -m4_divert(0)dnl -@output @output_parser_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])[ @@ -149,6 +151,7 @@ b4_copyright([Skeleton implementation for Bison's Yacc-like parsers in C],dnl ' USER NAME SPACE" below. */ ]b4_identification +b4_percent_code_get([[top]])[]dnl m4_if(b4_prefix, [yy], [], [/* Substitute the variable and function names. */ #define yyparse b4_prefix[]parse @@ -161,7 +164,7 @@ m4_if(b4_prefix, [yy], [], b4_locations_if([#define yylloc b4_prefix[]lloc])])[ /* Copy the first part of user declarations. */ -]b4_pre_prologue[ +]b4_user_pre_prologue[ /* Enabling traces. */ #ifndef YYDEBUG @@ -181,21 +184,22 @@ b4_locations_if([#define yylloc b4_prefix[]lloc])])[ # define YYTOKEN_TABLE ]b4_token_table[ #endif -]m4_ifdef([b4_start_header], -[[/* Copy the %start-header blocks. */ -]b4_start_header])[]dnl +]b4_percent_code_get([[requires]])[]dnl b4_token_enums_defines(b4_tokens)[ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED ]m4_ifdef([b4_stype], -[[typedef union ]b4_union_name -b4_user_stype - YYSTYPE;], -[typedef int YYSTYPE;])[ +[[typedef union ]b4_union_name[ +{ +]b4_user_stype[ +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1]], +[m4_if(b4_tag_seen_flag, 0, +[[typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1]])])[ # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif ]b4_locations_if([#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED @@ -211,14 +215,13 @@ typedef struct YYLTYPE # define YYLTYPE_IS_TRIVIAL 1 #endif]) -m4_ifdef([b4_end_header], -[[/* Copy the %end-header blocks. */ -]b4_end_header])[]dnl +b4_percent_code_get([[provides]])[]dnl [/* Copy the second part of user declarations. */ -]b4_user_post_prologue[ +]b4_user_post_prologue +b4_percent_code_get[]dnl -#ifdef short +[#ifdef short # undef short #endif @@ -710,12 +713,12 @@ do { \ /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &]b4_rhs_value(yynrhs, yyi + 1)[ ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl b4_user_args[); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, "\n"); } } @@ -1162,6 +1165,9 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1211,9 +1217,6 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) @@ -1222,9 +1225,8 @@ yybackup: /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1416,9 +1418,6 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; ]b4_locations_if([[ yyerror_range[1] = yylloc; @@ -1448,7 +1447,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1459,7 +1458,7 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) + if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[); /* Do not reclaim the symbols of the rule which action triggered @@ -1487,25 +1486,26 @@ yyreturn: b4_epilogue b4_defines_if( -[@output @output_header_name@ +[@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_start_header], -[[/* Copy the %start-header blocks. */ -]b4_start_header])[]dnl +b4_percent_code_get([[requires]])[]dnl b4_token_enums_defines(b4_tokens) [#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED ]m4_ifdef([b4_stype], -[[typedef union ]b4_union_name -b4_user_stype - YYSTYPE;], -[typedef int YYSTYPE;])[ +[[typedef union ]b4_union_name[ +{ +]b4_user_stype[ +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1]], +[m4_if(b4_tag_seen_flag, 0, +[[typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1]])])[ # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif ]b4_pure_if([], @@ -1529,7 +1529,10 @@ typedef struct YYLTYPE [extern YYLTYPE b4_prefix[]lloc;]) )dnl b4_locations_if -m4_ifdef([b4_end_header], -[[/* Copy the %end-header blocks. */ -]b4_end_header])[]dnl +b4_percent_code_get([[provides]]) ])dnl b4_defines_if +m4_divert_pop(0) + +], +[m4_include(b4_pkgdatadir/[push.c])])], +[m4_include(b4_pkgdatadir/[push.c])])