summaryrefslogtreecommitdiff
path: root/perly.y
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2010-10-14 01:52:59 +0100
committerFather Chrysostomos <sprout@cpan.org>2010-10-21 05:53:25 -0700
commita7aaec61655ef1580eb319cf234db0f3d5c9981e (patch)
tree5897e4d98914cd94069fa936eb35f577d8d61c6e /perly.y
parent640d5d412e67683edc19515df4462d7bb4739ae2 (diff)
downloadperl-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.y20
1 files changed, 2 insertions, 18 deletions
diff --git a/perly.y b/perly.y
index da7bcb07e3..cc27ee295a 100644
--- a/perly.y
+++ b/perly.y
@@ -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