diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-10-31 13:49:21 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-10-31 13:49:21 +0900 |
commit | 1b59ad57ae2fa4cfccaab97f22f943333080ea0c (patch) | |
tree | 7118b71fdcc5a2ddca97185511780ad6817be9a3 /parse.y | |
parent | a46c220320778c29612b80ebf2fee28a81eaa380 (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.y | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -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 ; |