summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorydah <t.yudai92@gmail.com>2024-09-22 00:13:16 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2024-09-23 09:19:37 +0900
commitfeac2b4b77b337a637d80793c53b680e5697cab6 (patch)
tree60fee0d4bd0bb523aa24935abf9ec8a4a73a6b89 /parse.y
parent02b36f75721aa61d48e3031c71695837d7a8a410 (diff)
Implement CASE NODE keyword locations
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11661
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y10
1 files changed, 6 insertions, 4 deletions
diff --git a/parse.y b/parse.y
index 09a786ccdd..550f00d56b 100644
--- a/parse.y
+++ b/parse.y
@@ -1063,7 +1063,7 @@ static rb_node_scope_t *rb_node_scope_new2(struct parser_params *p, rb_ast_id_ta
static rb_node_block_t *rb_node_block_new(struct parser_params *p, NODE *nd_head, const YYLTYPE *loc);
static rb_node_if_t *rb_node_if_new(struct parser_params *p, NODE *nd_cond, NODE *nd_body, NODE *nd_else, const YYLTYPE *loc);
static rb_node_unless_t *rb_node_unless_new(struct parser_params *p, NODE *nd_cond, NODE *nd_body, NODE *nd_else, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *then_keyword_loc, const YYLTYPE *end_keyword_loc);
-static rb_node_case_t *rb_node_case_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, const YYLTYPE *loc);
+static rb_node_case_t *rb_node_case_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *case_keyword_loc, const YYLTYPE *end_keyword_loc);
static rb_node_case2_t *rb_node_case2_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc);
static rb_node_case3_t *rb_node_case3_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, const YYLTYPE *loc);
static rb_node_when_t *rb_node_when_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, NODE *nd_next, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *then_keyword_loc);
@@ -1171,7 +1171,7 @@ static rb_node_error_t *rb_node_error_new(struct parser_params *p, const YYLTYPE
#define NEW_BLOCK(a,loc) (NODE *)rb_node_block_new(p,a,loc)
#define NEW_IF(c,t,e,loc) (NODE *)rb_node_if_new(p,c,t,e,loc)
#define NEW_UNLESS(c,t,e,loc,k_loc,t_loc,e_loc) (NODE *)rb_node_unless_new(p,c,t,e,loc,k_loc,t_loc,e_loc)
-#define NEW_CASE(h,b,loc) (NODE *)rb_node_case_new(p,h,b,loc)
+#define NEW_CASE(h,b,loc,ck_loc,ek_loc) (NODE *)rb_node_case_new(p,h,b,loc,ck_loc,ek_loc)
#define NEW_CASE2(b,loc) (NODE *)rb_node_case2_new(p,b,loc)
#define NEW_CASE3(h,b,loc) (NODE *)rb_node_case3_new(p,h,b,loc)
#define NEW_WHEN(c,t,e,loc,k_loc,t_loc) (NODE *)rb_node_when_new(p,c,t,e,loc,k_loc,t_loc)
@@ -4550,7 +4550,7 @@ primary : literal
{
if (CASE_LABELS_ENABLED_P(p->case_labels)) st_free_table(p->case_labels);
p->case_labels = $4;
- $$ = NEW_CASE($2, $5, &@$);
+ $$ = NEW_CASE($2, $5, &@$, &@1, &@6);
fixpos($$, $2);
/*% ripper: case!($:2, $:5) %*/
}
@@ -11613,11 +11613,13 @@ rb_node_lambda_new(struct parser_params *p, rb_node_args_t *nd_args, NODE *nd_bo
}
static rb_node_case_t *
-rb_node_case_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, const YYLTYPE *loc)
+rb_node_case_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *case_keyword_loc, const YYLTYPE *end_keyword_loc)
{
rb_node_case_t *n = NODE_NEWNODE(NODE_CASE, rb_node_case_t, loc);
n->nd_head = nd_head;
n->nd_body = nd_body;
+ n->case_keyword_loc = *case_keyword_loc;
+ n->end_keyword_loc = *end_keyword_loc;
return n;
}