X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/b5bbe64ad2ec51417ef02ac52304ed45fe37be3f..9cea1b144d6a5c138a4576a9d70366d1949a51db:/perly.c?ds=sidebyside diff --git a/perly.c b/perly.c index eb25893..5aed628 100644 --- a/perly.c +++ b/perly.c @@ -48,6 +48,10 @@ typedef signed char yysigned_char; # define YY_NULL 0 #endif +#ifndef YY_NULLPTR +# define YY_NULLPTR NULL +#endif + /* contains all the parser state tables; auto-generated from perly.y */ #include "perly.tab" @@ -169,8 +173,14 @@ yy_reduce_print (pTHX_ int yyrule) YYFPRINTF (Perl_debug_log, "Reducing stack by rule %d (line %u), ", yyrule - 1, yylineno); /* Print the symbols being reduced, and their result. */ +#if PERL_BISON_VERSION >= 30000 /* 3.0+ */ + for (yyi = 0; yyi < yyr2[yyrule]; yyi++) + YYFPRINTF (Perl_debug_log, "%s ", + yytname [yystos[(PL_parser->ps)[yyi + 1 - yyr2[yyrule]].state]]); +#else for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) YYFPRINTF (Perl_debug_log, "%s ", yytname [yyrhs[yyi]]); +#endif YYFPRINTF (Perl_debug_log, "-> %s\n", yytname [yyr1[yyrule]]); } @@ -213,7 +223,7 @@ S_clear_yystack(pTHX_ const yy_parser *parser) if (yy_type_tab[yystos[ps->state]] == toketype_opval && ps->val.opval) { - if (ps->compcv != PL_compcv) { + if (ps->compcv && (ps->compcv != PL_compcv)) { PL_compcv = ps->compcv; PAD_SET_CUR_NOSAVE(CvPADLIST(PL_compcv), 1); PL_comppad_name = PadlistNAMES(CvPADLIST(PL_compcv)); @@ -236,7 +246,6 @@ S_clear_yystack(pTHX_ const yy_parser *parser) int Perl_yyparse (pTHX_ int gramtype) { - dVAR; int yystate; int yyn; int yyresult; @@ -319,17 +328,8 @@ Perl_yyparse (pTHX_ int gramtype) /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (parser->yychar == YYEMPTY) { - YYDPRINTF ((Perl_debug_log, "Reading a token: ")); + YYDPRINTF ((Perl_debug_log, "Reading a token:\n")); parser->yychar = yylex(); - -/* perly.tab is shipped based on an ASCII system; if it were to be regenerated - * on a platform that doesn't use ASCII, this translation back would need to be - * removed */ -# ifdef EBCDIC - if (parser->yychar >= 0 && parser->yychar < 255) { - parser->yychar = NATIVE_TO_LATIN1(parser->yychar); - } -# endif } if (parser->yychar <= YYEOF) { @@ -337,7 +337,16 @@ Perl_yyparse (pTHX_ int gramtype) YYDPRINTF ((Perl_debug_log, "Now at end of input.\n")); } else { - yytoken = YYTRANSLATE (parser->yychar); + /* perly.tab is shipped based on an ASCII system, so need to index it + * with characters translated to ASCII. Although it's not designed for + * this purpose, we can use NATIVE_TO_UNI here. It returns its + * argument on ASCII platforms, and on EBCDIC translates native to + * ascii in the 0-255 range, leaving everything else unchanged. This + * jibes with yylex() returning some bare characters in that range, but + * all tokens it returns are either 0, or above 255. There could be a + * problem if NULs weren't 0, or were ever returned as raw chars by + * yylex() */ + yytoken = YYTRANSLATE (NATIVE_TO_UNI(parser->yychar)); YYDSYMPRINTF ("Next token is", yytoken, &parser->yylval); } @@ -578,11 +587,5 @@ Perl_yyparse (pTHX_ int gramtype) } /* - * Local variables: - * c-indentation-style: bsd - * c-basic-offset: 4 - * indent-tabs-mode: nil - * End: - * * ex: set ts=8 sts=4 sw=4 et: */