typedef short int yytype_int16;
typedef signed char yysigned_char;
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#define YYINITDEPTH 200
+
#ifdef DEBUGGING
# define YYDEBUG 1
#else
yy_stack_frame *ps = parser->ps;
int i = 0;
- if (!parser->stack || ps == parser->stack)
+ if (!parser->stack)
return;
YYDPRINTF ((Perl_debug_log, "clearing the parse stack\n"));
SvREFCNT_dec(ps->compcv);
ps--;
}
+
+ Safefree(parser->stack);
}
int
#ifdef PERL_IN_MADLY_C
-Perl_madparse (pTHX)
+Perl_madparse (pTHX_ int gramtype)
#else
-Perl_yyparse (pTHX)
+Perl_yyparse (pTHX_ int gramtype)
#endif
{
dVAR;
#ifndef PERL_IN_MADLY_C
# ifdef PERL_MAD
if (PL_madskills)
- return madparse();
+ return madparse(gramtype);
# endif
#endif
YYDPRINTF ((Perl_debug_log, "Starting parse\n"));
parser = PL_parser;
- ps = parser->ps;
- ENTER; /* force parser stack cleanup before we return */
+ ENTER; /* force parser state cleanup/restoration before we return */
+ SAVEPPTR(parser->yylval.pval);
+ SAVEINT(parser->yychar);
+ SAVEINT(parser->yyerrstatus);
+ SAVEINT(parser->stack_size);
+ SAVEINT(parser->yylen);
+ SAVEVPTR(parser->stack);
+ SAVEVPTR(parser->ps);
+
+ /* initialise state for this parse */
+ parser->yychar = gramtype;
+ parser->yyerrstatus = 0;
+ parser->stack_size = YYINITDEPTH;
+ parser->yylen = 0;
+ Newx(parser->stack, YYINITDEPTH, yy_stack_frame);
+ ps = parser->ps = parser->stack;
+ ps->state = 0;
SAVEDESTRUCTOR_X(S_clear_yystack, parser);
/*------------------------------------------------------------.
YYPUSHSTACK;
ps->state = yyn;
ps->val = parser->yylval;
- ps->compcv = SvREFCNT_inc(PL_compcv);
+ ps->compcv = (CV*)SvREFCNT_inc(PL_compcv);
ps->savestack_ix = PL_savestack_ix;
#ifdef DEBUGGING
ps->name = (const char *)(yytname[yytoken]);
number reduced by. */
ps->val = yyval;
- ps->compcv = SvREFCNT_inc(PL_compcv);
+ ps->compcv = (CV*)SvREFCNT_inc(PL_compcv);
ps->savestack_ix = PL_savestack_ix;
#ifdef DEBUGGING
ps->name = (const char *)(yytname [yyr1[yyn]]);
}
YYDSYMPRINTF ("Error: discarding", yytoken, &parser->yylval);
+ if (yy_type_tab[yytoken] == toketype_opval)
+ op_free(parser->yylval.opval);
parser->yychar = YYEMPTY;
}
YYPUSHSTACK;
ps->state = yyn;
ps->val = parser->yylval;
- ps->compcv = SvREFCNT_inc(PL_compcv);
+ ps->compcv = (CV*)SvREFCNT_inc(PL_compcv);
ps->savestack_ix = PL_savestack_ix;
#ifdef DEBUGGING
ps->name ="<err>";