X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/d6645148013be7c2abb641fcebe68d48af1a3739..fa7b79c063589793d5786be7906d3b52b1732636:/data/yacc.c diff --git a/data/yacc.c b/data/yacc.c index 289bee8a..74a014f1 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -160,8 +160,6 @@ 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[ @@ -183,17 +181,23 @@ 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_token_enums_defines(b4_tokens)[ + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED ]m4_ifdef([b4_stype], -[typedef union[]m4_bregexp(b4_stype, [^{], [ YYSTYPE]) -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,14 +211,14 @@ 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 +m4_ifdef([b4_end_header], +[[/* Copy the %end-header blocks. */ +]b4_end_header])[]dnl -/* Line __line__ of yacc.c. */ -b4_syncline([@oline@], [@ofile@])[ +[/* Copy the second part of user declarations. */ +]b4_user_post_prologue[ #ifdef short # undef short @@ -284,9 +288,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 +675,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"); } @@ -693,9 +700,9 @@ do { \ ]b4_c_function_def([yy_reduce_print], [static void], [[YYSTYPE *yyvsp], [yyvsp]], - b4_locations_if([[[YYLTYPE *yylsp], [yylsp]],]) - [[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,]) - b4_parse_param)[ + b4_locations_if([[[YYLTYPE *yylsp], [yylsp]], + ])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [, + ])b4_parse_param)[ { int yynrhs = yyr2[yyrule]; int yyi; @@ -964,15 +971,15 @@ yysyntax_error (char *yyresult, int yystate, int yychar) # Declare the variables that are global, or local to YYPARSE if # pure-parser. m4_define([b4_declare_parser_variables], -[/* The look-ahead symbol. */ +[/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs;b4_locations_if([ -/* Location data for the look-ahead symbol. */ +/* Location data for the lookahead symbol. */ YYLTYPE yylloc;]) ]) m4_divert_pop([KILL])dnl# ====================== End of M4 code. @@ -997,7 +1004,7 @@ b4_c_function_def([yyparse], [int], b4_parse_param) int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ + /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ @@ -1062,20 +1069,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 +1164,9 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1168,16 +1175,16 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1209,20 +1216,16 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* 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 +1266,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); @@ -1341,7 +1342,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1358,7 +1359,7 @@ yyerrlab: } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1416,14 +1417,11 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; ]b4_locations_if([[ yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of - the look-ahead. YYLOC is available though. */ + the lookahead. YYLOC is available though. */ YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc;]])[ @@ -1459,7 +1457,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 @@ -1480,7 +1478,8 @@ yyreturn: if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif - return yyresult; + /* Make sure YYID is used. */ + return YYID (yyresult); ]} @@ -1490,22 +1489,26 @@ b4_defines_if( 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_token_enums_defines(b4_tokens) -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -m4_ifdef([b4_stype], -[typedef union[]m4_bregexp(b4_stype, [^{], [ YYSTYPE]) -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( @@ -1522,7 +1525,11 @@ 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 + +m4_ifdef([b4_end_header], +[[/* Copy the %end-header blocks. */ +]b4_end_header])[]dnl ])dnl b4_defines_if