X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/1b818f33ad29193a8ccd1deb2bfec3f6d406d41a..75ad86eebd3f49dff81976eb83036eb7b7793e68:/data/yacc.c diff --git a/data/yacc.c b/data/yacc.c index 7b1e12c4..4ec1f4a1 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -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,9 @@ 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. +b4_use_push_for_pull_if([m4_include(b4_pkgdatadir/[push.c])], [ + m4_include(b4_pkgdatadir/[c.m4]) ## ---------------- ## @@ -133,8 +136,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 +152,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 @@ -160,10 +164,8 @@ m4_if(b4_prefix, [yy], [], #define yynerrs b4_prefix[]nerrs b4_locations_if([#define yylloc b4_prefix[]lloc])])[ -]b4_token_enums_defines(b4_tokens)[ - /* Copy the first part of user declarations. */ -]b4_pre_prologue[ +]b4_user_pre_prologue[ /* Enabling traces. */ #ifndef YYDEBUG @@ -183,17 +185,22 @@ b4_locations_if([#define yylloc b4_prefix[]lloc])])[ # define YYTOKEN_TABLE ]b4_token_table[ #endif +]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_stype -/* Line __line__ of yacc.c. */ -b4_syncline([@oline@], [@ofile@]) - 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 @@ -207,16 +214,15 @@ typedef struct YYLTYPE # define yyltype YYLTYPE /* obsolescent; will be withdrawn */ # define YYLTYPE_IS_DECLARED 1 # define YYLTYPE_IS_TRIVIAL 1 -#endif -])[ +#endif]) -/* Copy the second part of user declarations. */ -]b4_post_prologue +b4_percent_code_get([[provides]])[]dnl -/* Line __line__ of yacc.c. */ -b4_syncline([@oline@], [@ofile@])[ +[/* Copy the second part of user declarations. */ +]b4_user_post_prologue +b4_percent_code_get[]dnl -#ifdef short +[#ifdef short # undef short #endif @@ -284,9 +290,9 @@ typedef short int yytype_int16; #ifndef lint # define YYID(n) (n) #else -]b4_c_function_def([YYID], [static int], [[int i], [i]])[ +]b4_c_function_def([YYID], [static int], [[int yyi], [yyi]])[ { - return i; + return yyi; } #endif @@ -671,12 +677,15 @@ do { \ `------------------------------------------------------------------*/ ]b4_c_function_def([yy_stack_print], [static void], - [[yytype_int16 *bottom], [bottom]], - [[yytype_int16 *top], [top]])[ + [[yytype_int16 *yybottom], [yybottom]], + [[yytype_int16 *yytop], [yytop]])[ { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -705,12 +714,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"); } } @@ -1062,20 +1071,17 @@ b4_c_function_def([yyparse], [int], b4_parse_param) ]b4_locations_if([[ yylsp = yyls; #if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ - yylloc.first_line = yylloc.last_line = 1; - yylloc.first_column = yylloc.last_column = 0; + yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[; + yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[; #endif ]]) m4_ifdef([b4_initial_action], [ m4_pushdef([b4_at_dollar], [m4_define([b4_at_dollar_used])yylloc])dnl m4_pushdef([b4_dollar_dollar], [m4_define([b4_dollar_dollar_used])yylval])dnl /* User initialization code. */ -b4_initial_action + b4_user_initial_action m4_popdef([b4_dollar_dollar])dnl -m4_popdef([b4_at_dollar])dnl -/* Line __line__ of yacc.c. */ -b4_syncline([@oline@], [@ofile@]) -])dnl +m4_popdef([b4_at_dollar])])dnl m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval; ]])dnl m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; @@ -1160,6 +1166,9 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1209,9 +1218,6 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) @@ -1220,9 +1226,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; @@ -1263,9 +1268,7 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - ]b4_actions -/* Line __line__ of yacc.c. */ -b4_syncline([@oline@], [@ofile@])[ + ]b4_user_actions[ default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1416,9 +1419,6 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; ]b4_locations_if([[ yyerror_range[1] = yylloc; @@ -1459,7 +1459,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,26 +1487,29 @@ 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]) +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_stype -/* Line __line__ of yacc.c. */ -b4_syncline([@oline@], [@ofile@]) - YYSTYPE;], -[typedef int YYSTYPE;]) +[#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +]m4_ifdef([b4_stype], +[[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([], +]b4_pure_if([], [extern YYSTYPE b4_prefix[]lval;]) b4_locations_if( @@ -1523,7 +1526,12 @@ typedef struct YYLTYPE # define YYLTYPE_IS_TRIVIAL 1 #endif -b4_pure_if([], +]b4_pure_if([], [extern YYLTYPE b4_prefix[]lloc;]) -])dnl b4_locations_if +)dnl b4_locations_if + +b4_percent_code_get([[provides]]) ])dnl b4_defines_if +m4_divert_pop(0) + +])dnl b4_use_push_for_pull_if