From e3abe207f764929a97eafa503a3780d5b7636ed2 Mon Sep 17 00:00:00 2001 From: Dave Mitchell Date: Sun, 1 Apr 2007 01:27:57 +0000 Subject: Make parser_free() be called slightly later, i.e. at the point where lexer vars are being restored in a LEAVE, rather than at the end of yyparse() p4raw-id: //depot/perl@30822 --- toke.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'toke.c') diff --git a/toke.c b/toke.c index a9e3d880a0..d11cdcc9b8 100644 --- a/toke.c +++ b/toke.c @@ -615,8 +615,7 @@ S_cr_textfilter(pTHX_ int idx, SV *sv, int maxlen) /* * 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 @@ -641,6 +640,9 @@ Perl_lex_start(pTHX_ SV *line) 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); @@ -713,6 +715,20 @@ Perl_lex_start(pTHX_ SV *line) 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 -- cgit v1.2.1