From 28ac2b49dea6847c95a32afde577935fec51650f Mon Sep 17 00:00:00 2001 From: Zefram Date: Sat, 21 Aug 2010 18:54:04 +0100 Subject: function interface to parse Perl statement yyparse() becomes reentrant. The yacc stack and related resources are allocated in yyparse(), rather than in lex_start(), and they are localised to yyparse(), preserving their values from any outer parser. yyparse() now takes a parameter which determines which production it will parse at the top level. New API function parse_fullstmt() uses this facility to parse just a single statement. The top-level single-statement production that is used for this then messes with the parser's head so that the parsing stops without seeing EOF, and any lookahead token seen after the statement is pushed back to the lexer. --- embed.fnc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'embed.fnc') diff --git a/embed.fnc b/embed.fnc index 63269f0f7e..ecb6e71f8c 100644 --- a/embed.fnc +++ b/embed.fnc @@ -622,6 +622,8 @@ AMpd |bool |lex_next_chunk |U32 flags AMpd |I32 |lex_peek_unichar|U32 flags AMpd |I32 |lex_read_unichar|U32 flags AMpd |void |lex_read_space |U32 flags +: Public parser API +AMpd |OP* |parse_fullstmt |U32 flags : Used in various files Ap |void |op_null |NN OP* o : FIXME. Used by Data::Alias @@ -1326,8 +1328,9 @@ p |void |write_to_stderr|NN SV* msv p |int |yyerror |NN const char *const s : Used in perly.y, and by Data::Alias EXp |int |yylex +p |void |yyunlex : Used in perl.c, pp_ctl.c -p |int |yyparse +p |int |yyparse |int gramtype : Only used in scope.c p |void |parser_free |NN const yy_parser *parser #if defined(PERL_IN_TOKE_C) @@ -2341,7 +2344,7 @@ s |void |start_force |int where s |void |curmad |char slot|NULLOK SV *sv # endif Mp |int |madlex -Mp |int |madparse +Mp |int |madparse |int gramtype #endif #if !defined(HAS_SIGNBIT) AMdnoP |int |Perl_signbit |NV f -- cgit v1.2.1