aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-10-23 15:16:25 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-10-23 17:40:33 +0900
commit7e80f0b5a2eefc8599990a8ec826c555d2378374 (patch)
treed7ce7d4a0aea3fc7f608a7bc9b1fbf3e32e0b8d2 /parse.y
parent428f9f5dc067f73e553f9947c587a8bdd53972be (diff)
downloadruby-7e80f0b5a2eefc8599990a8ec826c555d2378374.tar.gz
Extract p_in_kwarg to save and update lexer contexts
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y28
1 files changed, 11 insertions, 17 deletions
diff --git a/parse.y b/parse.y
index ecf2aac52c..f0711e502b 100644
--- a/parse.y
+++ b/parse.y
@@ -2079,7 +2079,7 @@ get_nd_args(struct parser_params *p, NODE *node)
%type <id> p_kwrest p_kwnorest p_any_kwrest p_kw_label
%type <id> f_no_kwarg f_any_kwrest args_forward excessed_comma nonlocal_var def_name
%type <ctxt> lex_ctxt begin_defined k_class k_module k_END k_rescue k_ensure after_rescue
-%type <ctxt> p_assoc p_in
+%type <ctxt> p_in_kwarg
%type <tbl> p_lparen p_lbracket p_pktbl p_pvtbl
/* ripper */ %type <num> max_numparam
/* ripper */ %type <node> numparam
@@ -2633,14 +2633,11 @@ expr : command_call
{
$$ = call_uni_op(p, method_cond(p, $2, &@2), '!', &@1, &@$);
}
- | arg p_assoc[ctxt]
+ | arg tASSOC
{
value_expr($arg);
- SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
- p->command_start = FALSE;
- p->ctxt.in_kwarg = 1;
}
- p_pvtbl p_pktbl
+ p_in_kwarg[ctxt] p_pvtbl p_pktbl
p_top_expr_body[body]
{
pop_pktbl(p, $p_pktbl);
@@ -2651,14 +2648,11 @@ expr : command_call
/*% %*/
/*% ripper: case!($arg, in!($body, Qnil, Qnil)) %*/
}
- | arg p_in[ctxt]
+ | arg keyword_in
{
value_expr($arg);
- SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
- p->command_start = FALSE;
- p->ctxt.in_kwarg = 1;
}
- p_pvtbl p_pktbl
+ p_in_kwarg[ctxt] p_pvtbl p_pktbl
p_top_expr_body[body]
{
pop_pktbl(p, $p_pktbl);
@@ -5037,16 +5031,16 @@ cases : opt_else
p_pvtbl : {$$ = p->pvtbl; p->pvtbl = st_init_numtable();};
p_pktbl : {$$ = p->pktbl; p->pktbl = 0;};
-p_assoc : tASSOC lex_ctxt {$$ = $2;};
-p_in : keyword_in lex_ctxt {$$ = $2;};
-
-p_case_body : p_in[ctxt]
- {
+p_in_kwarg : {
+ $$ = p->ctxt;
SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
p->command_start = FALSE;
p->ctxt.in_kwarg = 1;
}
- p_pvtbl p_pktbl
+ ;
+
+p_case_body : keyword_in
+ p_in_kwarg[ctxt] p_pvtbl p_pktbl
p_top_expr[expr] then
{
pop_pktbl(p, $p_pktbl);