This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Regenerate reentr.[ch]
[perl5.git] / perly.c
diff --git a/perly.c b/perly.c
index b18e202..12c8443 100644 (file)
--- a/perly.c
+++ b/perly.c
@@ -76,10 +76,6 @@ while (0)
 #define YYTERROR       1
 #define YYERRCODE      256
 
-/* YYLEX -- calling `yylex' with the right arguments.  */
-
-# define YYLEX yylex_r (&yylval, &yychar)
-
 /* Enable debugging if requested.  */
 #ifdef DEBUGGING
 
@@ -113,26 +109,19 @@ do {                                                              \
 `--------------------------------*/
 
 static void
-yysymprint (pTHX_ PerlIO *yyoutput, int yytype, YYSTYPE *yyvaluep)
+yysymprint (pTHX_ PerlIO *yyoutput, int yytype, const YYSTYPE *yyvaluep)
 {
-    /* Pacify ``unused variable'' warnings.  */
-    (void) yyvaluep;
-
     if (yytype < YYNTOKENS) {
        YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
 #   ifdef YYPRINT
        YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
 #   else
-       YYFPRINTF (yyoutput, "0x%x", yyvaluep->ival);
+       YYFPRINTF (yyoutput, "0x%"UVxf, (UV)yyvaluep->ival);
 #   endif
     }
     else
        YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
 
-    switch (yytype) {
-       default:
-           break;
-    }
     YYFPRINTF (yyoutput, ")");
 }
 
@@ -142,7 +131,7 @@ yysymprint (pTHX_ PerlIO *yyoutput, int yytype, YYSTYPE *yyvaluep)
  *  meanings as the local vars in yyparse() of the same name */
 
 static void
-yy_stack_print (pTHX_ short *yyss, short *yyssp, YYSTYPE *yyvs, char**yyns)
+yy_stack_print (pTHX_ const short *yyss, const short *yyssp, const YYSTYPE *yyvs, const char**yyns)
 {
     int i;
     int start = 1;
@@ -164,7 +153,7 @@ yy_stack_print (pTHX_ short *yyss, short *yyssp, YYSTYPE *yyvs, char**yyns)
        PerlIO_printf(Perl_debug_log, " %8.8s", *yyns);
     PerlIO_printf(Perl_debug_log, "\nvalue:");
     for (i=0, yyvs += start; i < count; i++, yyvs++)
-       PerlIO_printf(Perl_debug_log, " %8x", yyvs->ival);
+       PerlIO_printf(Perl_debug_log, " %8"UVxf, (UV)yyvs->ival);
     PerlIO_printf(Perl_debug_log, "\n\n");
 }
 
@@ -183,7 +172,7 @@ static void
 yy_reduce_print (pTHX_ int yyrule)
 {
     int yyi;
-    unsigned int yylineno = yyrline[yyrule];
+    const unsigned int yylineno = yyrline[yyrule];
     YYFPRINTF (Perl_debug_log, "Reducing stack by rule %d (line %u), ",
                          yyrule - 1, yylineno);
     /* Print the symbols being reduced, and their result.  */
@@ -254,26 +243,6 @@ yystpcpy (pTHX_ char *yydest, const char *yysrc)
 
 #endif /* !YYERROR_VERBOSE */
 
-
-/*-----------------------------------------------.
-| Release the memory associated to this symbol.  |
-`-----------------------------------------------*/
-
-static void
-yydestruct (int yytype, YYSTYPE *yyvaluep)
-{
-    /* Pacify ``unused variable'' warnings.  */
-    (void) yyvaluep;
-
-    switch (yytype) {
-       default:
-           break;
-    }
-}
-
-
-
-
 /*----------.
 | yyparse.  |
 `----------*/
@@ -314,7 +283,7 @@ Perl_yyparse (pTHX)
 
 #ifdef DEBUGGING
     /* maintain also a stack of token/rule names for debugging with -Dpv */
-    char **yyns, **yynsp;
+    const char **yyns, **yynsp;
     SV *yyns_sv;
 #  define YYPOPSTACK   (yyvsp--, yyssp--, yynsp--)
 #else
@@ -335,11 +304,12 @@ Perl_yyparse (pTHX)
 
     YYDPRINTF ((Perl_debug_log, "Starting parse\n"));
 
-#ifdef USE_ITHREADS
-    /* XXX is this needed anymore? DAPM 13-Feb-04;
-     * if not, delete the correspinding LEAVE too */
     ENTER;                     /* force stack free before we return */
-#endif
+    SAVEVPTR(PL_yycharp);
+    SAVEVPTR(PL_yylvalp);
+    PL_yycharp = &yychar; /* so PL_yyerror() can access it */
+    PL_yylvalp = &yylval; /* so various functions in toke.c can access it */
+
     yyss_sv = NEWSV(73, YYINITDEPTH * sizeof(short));
     yyvs_sv = NEWSV(73, YYINITDEPTH * sizeof(YYSTYPE));
     SAVEFREESV(yyss_sv);
@@ -352,7 +322,7 @@ Perl_yyparse (pTHX)
 #ifdef DEBUGGING
     yyns_sv = NEWSV(73, YYINITDEPTH * sizeof(char *));
     SAVEFREESV(yyns_sv);
-    yyns = (char **) SvPVX(yyns_sv);
+    yyns = (const char **) SvPVX(yyns_sv);
     yynsp = yyns;
 #endif
 
@@ -381,7 +351,7 @@ Perl_yyparse (pTHX)
 
     if (yyss + yystacksize - 1 <= yyssp) {
         /* Get the current used size of the three stacks, in elements.  */
-        YYSIZE_T yysize = yyssp - yyss + 1;
+        const YYSIZE_T yysize = yyssp - yyss + 1;
 
         /* Extend the stack our own way.  */
         if (YYMAXDEPTH <= yystacksize)
@@ -396,7 +366,7 @@ Perl_yyparse (pTHX)
         yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
 #ifdef DEBUGGING
         SvGROW(yyns_sv, yystacksize * sizeof(char *));
-        yyns = (char **) SvPVX(yyns_sv);
+        yyns = (const char **) SvPVX(yyns_sv);
         if (! yyns)
               goto yyoverflowlab;
         yynsp = yyns + yysize - 1;
@@ -437,7 +407,12 @@ Perl_yyparse (pTHX)
     /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
     if (yychar == YYEMPTY) {
        YYDPRINTF ((Perl_debug_log, "Reading a token: "));
-       yychar = YYLEX;
+       yychar = yylex();
+#  ifdef EBCDIC
+       if (yychar >= 0 && yychar < 255) {
+           yychar = NATIVE_TO_ASCII(yychar);
+       }
+#  endif
     }
 
     if (yychar <= YYEOF) {
@@ -474,7 +449,7 @@ Perl_yyparse (pTHX)
 
     *++yyvsp = yylval;
 #ifdef DEBUGGING
-    *++yynsp = (char *)(yytname[yytoken]);
+    *++yynsp = (const char *)(yytname[yytoken]);
 #endif
 
 
@@ -536,7 +511,7 @@ Perl_yyparse (pTHX)
 
     *++yyvsp = yyval;
 #ifdef DEBUGGING
-    *++yynsp = (char *)(yytname [yyr1[yyn]]);
+    *++yynsp = (const char *)(yytname [yyr1[yyn]]);
 #endif
 
     /* Now `shift' the result of the reduction.  Determine what state
@@ -577,7 +552,7 @@ Perl_yyparse (pTHX)
 
        if (YYPACT_NINF < yyn && yyn < YYLAST) {
            YYSIZE_T yysize = 0;
-           int yytype = YYTRANSLATE (yychar);
+           const int yytype = YYTRANSLATE (yychar);
            char *yymsg;
            int yyx, yycount;
 
@@ -592,7 +567,7 @@ Perl_yyparse (pTHX)
            yysize += yystrlen (yytname[yytype]);
            New(yymsg, yysize, char *);
            if (yymsg != 0) {
-               char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
+               const char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
                yyp = yystpcpy (yyp, yytname[yytype]);
 
                if (yycount < 5) {
@@ -633,14 +608,12 @@ Perl_yyparse (pTHX)
            /* Pop the rest of the stack.  */
            while (yyss < yyssp) {
                YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
-               yydestruct (yystos[*yyssp], yyvsp);
                YYPOPSTACK;
            }
            YYABORT;
        }
 
        YYDSYMPRINTF ("Error: discarding", yytoken, &yylval);
-       yydestruct (yytoken, &yylval);
        yychar = YYEMPTY;
 
     }
@@ -672,7 +645,6 @@ Perl_yyparse (pTHX)
            YYABORT;
 
        YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
-       yydestruct (yystos[yystate], yyvsp);
        yyvsp--;
 #ifdef DEBUGGING
        yynsp--;
@@ -722,9 +694,17 @@ Perl_yyparse (pTHX)
 
   yyreturn:
 
-#ifdef USE_ITHREADS
-       LEAVE;                  /* force stack free before we return */
-#endif
+    LEAVE;                     /* force stack free before we return */
 
     return yyresult;
 }
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 noet:
+*/