summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-10-31 13:49:21 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-10-31 13:49:21 +0900
commit1b59ad57ae2fa4cfccaab97f22f943333080ea0c (patch)
tree7118b71fdcc5a2ddca97185511780ad6817be9a3 /parse.y
parenta46c220320778c29612b80ebf2fee28a81eaa380 (diff)
Reduce parser stack usage at pattern matching
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5064
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y24
1 files changed, 12 insertions, 12 deletions
diff --git a/parse.y b/parse.y
index ec25402aec..14393abad0 100644
--- a/parse.y
+++ b/parse.y
@@ -1758,36 +1758,36 @@ expr : command_call
value_expr($1);
SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
p->command_start = FALSE;
- $<ctxt>$ = p->ctxt;
+ $<ctxt>2 = p->ctxt;
p->ctxt.in_kwarg = 1;
+ $<tbl>$ = push_pvtbl(p);
}
- {$<tbl>$ = push_pvtbl(p);}
p_top_expr_body
- {pop_pvtbl(p, $<tbl>4);}
{
- p->ctxt.in_kwarg = $<ctxt>3.in_kwarg;
+ pop_pvtbl(p, $<tbl>3);
+ p->ctxt.in_kwarg = $<ctxt>2.in_kwarg;
/*%%%*/
- $$ = NEW_CASE3($1, NEW_IN($5, 0, 0, &@5), &@$);
+ $$ = NEW_CASE3($1, NEW_IN($4, 0, 0, &@4), &@$);
/*% %*/
- /*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/
+ /*% ripper: case!($1, in!($4, Qnil, Qnil)) %*/
}
| arg keyword_in
{
value_expr($1);
SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
p->command_start = FALSE;
- $<ctxt>$ = p->ctxt;
+ $<ctxt>2 = p->ctxt;
p->ctxt.in_kwarg = 1;
+ $<tbl>$ = push_pvtbl(p);
}
- {$<tbl>$ = push_pvtbl(p);}
p_top_expr_body
- {pop_pvtbl(p, $<tbl>4);}
{
- p->ctxt.in_kwarg = $<ctxt>3.in_kwarg;
+ pop_pvtbl(p, $<tbl>3);
+ p->ctxt.in_kwarg = $<ctxt>1.in_kwarg;
/*%%%*/
- $$ = NEW_CASE3($1, NEW_IN($5, NEW_TRUE(&@5), NEW_FALSE(&@5), &@5), &@$);
+ $$ = NEW_CASE3($1, NEW_IN($4, NEW_TRUE(&@4), NEW_FALSE(&@4), &@4), &@$);
/*% %*/
- /*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/
+ /*% ripper: case!($1, in!($4, Qnil, Qnil)) %*/
}
| arg %prec tLBRACE_ARG
;