diff options
author | Zefram <zefram@fysh.org> | 2010-10-14 01:52:59 +0100 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2010-10-21 05:53:25 -0700 |
commit | a7aaec61655ef1580eb319cf234db0f3d5c9981e (patch) | |
tree | 5897e4d98914cd94069fa936eb35f577d8d61c6e /perly.y | |
parent | 640d5d412e67683edc19515df4462d7bb4739ae2 (diff) | |
download | perl-a7aaec61655ef1580eb319cf234db0f3d5c9981e.tar.gz |
handle bracket stack better in recdescent parsing
When recursing into the parser for recursive-descent parsing, put
a special entry on the bracket stack that generates a fake EOF if a
closing bracket belonging to an outer parser frame is seen. This keeps
the bracket stack balanced across a parse_stmtseq() frame, fixing
[perl #78222].
If a recursive-descent parser frame ends by yyunlex()ing an opening
bracket, pop its entry off the bracket stack and stash it in the
forced-token queue, to be revived when the token is re-lexed. This keeps
the bracket stack balanced across a parse_fullstmt() frame.
Diffstat (limited to 'perly.y')
-rw-r--r-- | perly.y | 20 |
1 files changed, 2 insertions, 18 deletions
@@ -89,7 +89,7 @@ %type <i_tkval> lpar_or_qw -%type <ival> grammar closebrace_or_eof prog progstart remember mremember +%type <ival> grammar prog progstart remember mremember %type <ival> startsub startanonsub startformsub /* FIXME for MAD - are these two ival? */ %type <ival> mydefsv mintro @@ -154,29 +154,13 @@ grammar : GRAMPROG prog { parser->expect = XSTATE; } - lineseq closebrace_or_eof + lineseq { PL_eval_root = $3; $$ = 0; } ; -closebrace_or_eof: '}' - { - assert(parser->yychar == YYEMPTY); - assert(parser->bufptr != SvPVX(parser->linestr)); - assert(parser->bufptr[-1] == '}'); - parser->bufptr--; - parser->lex_brackstack[parser->lex_brackets++] = - XSTATE; - parser->expect = XSTATE; - parser->yychar = YYEOF; - $$ = 0; - } - | /* NULL */ - { $$ = 0; } - ; - /* The whole program */ prog : progstart /*CONTINUED*/ lineseq |