diff options
| author | ydah <t.yudai92@gmail.com> | 2024-09-10 16:41:27 +0900 |
|---|---|---|
| committer | Yuichiro Kaneko <spiketeika@gmail.com> | 2024-09-11 18:01:16 +0900 |
| commit | d03e0d1c35638fcd3b474bf604c855f132356e6d (patch) | |
| tree | fc528b850c077ada83b5da5b20198c3a8abcde46 /parse.y | |
| parent | f7ffa76377ead1760dcb0a84db282facb461ecd7 (diff) | |
Implement BREAK, NEXT and REDO NODE locations
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11584
Diffstat (limited to 'parse.y')
| -rw-r--r-- | parse.y | 31 |
1 files changed, 17 insertions, 14 deletions
@@ -1313,15 +1313,15 @@ struct RNode_DEF_TEMP { #define RNODE_DEF_TEMP(node) ((struct RNode_DEF_TEMP *)(node)) -static rb_node_break_t *rb_node_break_new(struct parser_params *p, NODE *nd_stts, const YYLTYPE *loc); -static rb_node_next_t *rb_node_next_new(struct parser_params *p, NODE *nd_stts, const YYLTYPE *loc); -static rb_node_redo_t *rb_node_redo_new(struct parser_params *p, const YYLTYPE *loc); +static rb_node_break_t *rb_node_break_new(struct parser_params *p, NODE *nd_stts, const YYLTYPE *loc, const YYLTYPE *keyword_loc); +static rb_node_next_t *rb_node_next_new(struct parser_params *p, NODE *nd_stts, const YYLTYPE *loc, const YYLTYPE *keyword_loc); +static rb_node_redo_t *rb_node_redo_new(struct parser_params *p, const YYLTYPE *loc, const YYLTYPE *keyword_loc); static rb_node_def_temp_t *rb_node_def_temp_new(struct parser_params *p, const YYLTYPE *loc); static rb_node_def_temp_t *def_head_save(struct parser_params *p, rb_node_def_temp_t *n); -#define NEW_BREAK(s,loc) (NODE *)rb_node_break_new(p,s,loc) -#define NEW_NEXT(s,loc) (NODE *)rb_node_next_new(p,s,loc) -#define NEW_REDO(loc) (NODE *)rb_node_redo_new(p,loc) +#define NEW_BREAK(s,loc,k_loc) (NODE *)rb_node_break_new(p,s,loc,k_loc) +#define NEW_NEXT(s,loc,k_loc) (NODE *)rb_node_next_new(p,s,loc,k_loc) +#define NEW_REDO(loc,k_loc) (NODE *)rb_node_redo_new(p,loc,k_loc) #define NEW_DEF_TEMP(loc) rb_node_def_temp_new(p,loc) /* Make a new internal node, which should not be appeared in the @@ -3538,14 +3538,14 @@ command : fcall command_args %prec tLOWEST { NODE *args = 0; args = ret_args(p, $2); - $$ = add_block_exit(p, NEW_BREAK(args, &@$)); + $$ = add_block_exit(p, NEW_BREAK(args, &@$, &@1)); /*% ripper: break!($:2) %*/ } | keyword_next call_args { NODE *args = 0; args = ret_args(p, $2); - $$ = add_block_exit(p, NEW_NEXT(args, &@$)); + $$ = add_block_exit(p, NEW_NEXT(args, &@$, &@1)); /*% ripper: next!($:2) %*/ } ; @@ -4701,17 +4701,17 @@ primary : literal } | keyword_break { - $$ = add_block_exit(p, NEW_BREAK(0, &@$)); + $$ = add_block_exit(p, NEW_BREAK(0, &@$, &@1)); /*% ripper: break!(args_new!) %*/ } | keyword_next { - $$ = add_block_exit(p, NEW_NEXT(0, &@$)); + $$ = add_block_exit(p, NEW_NEXT(0, &@$, &@1)); /*% ripper: next!(args_new!) %*/ } | keyword_redo { - $$ = add_block_exit(p, NEW_REDO(&@$)); + $$ = add_block_exit(p, NEW_REDO(&@$, &@1)); /*% ripper: redo! %*/ } | keyword_retry @@ -12468,30 +12468,33 @@ rb_node_error_new(struct parser_params *p, const YYLTYPE *loc) } static rb_node_break_t * -rb_node_break_new(struct parser_params *p, NODE *nd_stts, const YYLTYPE *loc) +rb_node_break_new(struct parser_params *p, NODE *nd_stts, const YYLTYPE *loc, const YYLTYPE *keyword_loc) { rb_node_break_t *n = NODE_NEWNODE(NODE_BREAK, rb_node_break_t, loc); n->nd_stts = nd_stts; n->nd_chain = 0; + n->keyword_loc = *keyword_loc; return n; } static rb_node_next_t * -rb_node_next_new(struct parser_params *p, NODE *nd_stts, const YYLTYPE *loc) +rb_node_next_new(struct parser_params *p, NODE *nd_stts, const YYLTYPE *loc, const YYLTYPE *keyword_loc) { rb_node_next_t *n = NODE_NEWNODE(NODE_NEXT, rb_node_next_t, loc); n->nd_stts = nd_stts; n->nd_chain = 0; + n->keyword_loc = *keyword_loc; return n; } static rb_node_redo_t * -rb_node_redo_new(struct parser_params *p, const YYLTYPE *loc) +rb_node_redo_new(struct parser_params *p, const YYLTYPE *loc, const YYLTYPE *keyword_loc) { rb_node_redo_t *n = NODE_NEWNODE(NODE_REDO, rb_node_redo_t, loc); n->nd_chain = 0; + n->keyword_loc = *keyword_loc; return n; } |
