}
}
-/* delete a parser object */
-
-#ifndef PERL_IN_MADLY_C
-void
-Perl_parser_free(pTHX_ const yy_parser *parser)
-{
- S_clear_yystack(aTHX_ parser);
- Safefree(parser->stack);
- Safefree(parser->lex_brackstack);
- Safefree(parser->lex_casestack);
- PL_parser = parser->old_parser;
- Safefree(parser);
-}
-#endif
/*----------.
| yyparse. |
parser = PL_parser;
ps = parser->ps;
- ENTER; /* force parser free before we return */
- SAVEPARSER(parser);
+ ENTER; /* force parser stack cleanup before we return */
+ SAVEDESTRUCTOR_X(S_clear_yystack, parser);
/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate. |
goto yyreturn;
yyreturn:
- LEAVE; /* force parser free before we return */
+ LEAVE; /* force parser stack cleanup before we return */
return yyresult;
}
/*
* Perl_lex_start
- * Initialize variables. Uses the Perl save_stack to save its state (for
- * recursive calls to the parser).
+ * Create a parser object and initialise its parser and lexer fields
*/
void
parser->yyerrstatus = 0;
parser->yychar = YYEMPTY; /* Cause a token to be read. */
+ /* on scope exit, free this parser and restore any outer one */
+ SAVEPARSER(parser);
+
/* initialise lexer state */
SAVEI32(PL_lex_state);
PL_rsfp = 0;
}
+
+/* delete a parser object */
+
+void
+Perl_parser_free(pTHX_ const yy_parser *parser)
+{
+ Safefree(parser->stack);
+ Safefree(parser->lex_brackstack);
+ Safefree(parser->lex_casestack);
+ PL_parser = parser->old_parser;
+ Safefree(parser);
+}
+
+
/*
* Perl_lex_end
* Finalizer for lexing operations. Must be called when the parser is