X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/06e8700a000fb661a3d15db8e1dfeb6bfcccf86d..fd575f05a48abaa84be69fc49aad2b3a1b80ee0d:/data/glr.c diff --git a/data/glr.c b/data/glr.c index e66e1c61..37ba588c 100644 --- a/data/glr.c +++ b/data/glr.c @@ -21,6 +21,9 @@ m4_divert(-1) -*- C -*- m4_include(b4_pkgdatadir/[c.m4]) +b4_push_if([ +m4_fatal([Non-deterministic push parsers are not yet supported])]) + ## ---------------- ## ## Default values. ## ## ---------------- ## @@ -142,7 +145,7 @@ m4_define([b4_rhs_location], # We do want M4 expansion after # for CPP macros. m4_changecom() m4_divert(0)dnl -@output @output_parser_name@ +@output b4_parser_file_name b4_copyright([Skeleton implementation for Bison GLR parsers in C], [2002, 2003, 2004, 2005, 2006]) [ @@ -162,16 +165,16 @@ m4_if(b4_prefix, [yy], [], #define yylloc b4_prefix[]lloc])[ /* Copy the first part of user declarations. */ -]b4_pre_prologue +]b4_user_pre_prologue dnl # b4_shared_declarations dnl # ---------------------- dnl # Declaration that might either go into the header (if --defines) dnl # or open coded in the parser body. m4_define([b4_shared_declarations], -[m4_ifdef([b4_start_header], -[[/* Copy the %start-header blocks. */ -]b4_start_header])[]dnl +[m4_ifdef([b4_requires], +[[/* Copy the %requires blocks. */ +]b4_user_requires])[]dnl b4_token_enums(b4_tokens) @@ -202,12 +205,12 @@ typedef struct YYLTYPE # define YYLTYPE_IS_TRIVIAL 1 #endif -]m4_ifdef([b4_end_header], -[[/* Copy the %end-header blocks. */ -]b4_end_header])[]dnl +]m4_ifdef([b4_provides], +[[/* Copy the %provides blocks. */ +]b4_user_provides])[]dnl ]) -b4_defines_if([#include @output_header_name@], +b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]], [b4_shared_declarations])[ /* Enabling traces. */ @@ -241,7 +244,6 @@ static YYSTYPE yyval_default; #include #include #include -#include #ifndef YY_ # if YYENABLE_NLS @@ -346,8 +348,7 @@ static YYSTYPE yyval_default; #define YYMAXUTOK ]b4_user_token_number_max[ #define YYTRANSLATE(YYX) \ - ((YYX <= 0) ? YYEOF : \ - (unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const ]b4_int_type_for([b4_translate])[ yytranslate[] = @@ -1048,8 +1049,7 @@ yygetLRActions (yyStateNum yystate, int yytoken, int* yyaction, const short int** yyconflicts) { int yyindex = yypact[yystate] + yytoken; - if (yyindex < 0 || YYLAST < yyindex - || (]b4_safest_int_type[)yycheck[yyindex] != yytoken) + if (yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken) { *yyaction = -yydefact[yystate]; *yyconflicts = yyconfl; @@ -1071,8 +1071,7 @@ yyLRgotoState (yyStateNum yystate, yySymbol yylhs) { int yyr; yyr = yypgoto[yylhs - YYNTOKENS] + yystate; - if (0 <= yyr && yyr <= YYLAST - && (]b4_safest_int_type[)yycheck[yyr] == yystate) + if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate) return yytable[yyr]; else return yydefgoto[yylhs - YYNTOKENS]; @@ -2042,11 +2041,19 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk, { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } - else - yytoken = YYTRANSLATE (yychar); + yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts); while (*yyconflicts != 0) @@ -2122,8 +2129,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[) yyfmt = yystpcpy (yyformat, yyunexpected); for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if ((]b4_safest_int_type[)yycheck[yyx + yyn] == yyx - && yyx != YYTERROR) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { @@ -2213,14 +2219,21 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) } YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } yyj = yypact[yystackp->yytops.yystates[0]->yylrState]; if (yyis_pact_ninf (yyj)) return; yyj += yytoken; - if (yyj < 0 || YYLAST < yyj - || (]b4_safest_int_type[)yycheck[yyj] != yytoken) + if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != yytoken) { if (yydefact[yystackp->yytops.yystates[0]->yylrState] != 0) return; @@ -2367,11 +2380,19 @@ m4_popdef([b4_at_dollar])])dnl { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } - else - yytoken = YYTRANSLATE (yychar); + yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts); if (*yyconflicts != 0) break; @@ -2606,8 +2627,12 @@ yypdumpstack (yyGLRStack* yystackp) ] b4_epilogue -b4_defines_if( -[@output @output_header_name@ +dnl +dnl glr.cc produces its own header. +dnl +m4_if(b4_skeleton, ["glr.c"], +[b4_defines_if( +[@output b4_spec_defines_file b4_copyright([Skeleton interface for Bison GLR parsers in C], [2002, 2003, 2004, 2005, 2006]) @@ -2618,4 +2643,4 @@ extern YYSTYPE b4_prefix[]lval; b4_locations_if([b4_pure_if([], [extern YYLTYPE b4_prefix[]lloc;]) ]) -]) +])])