1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Include the entire lambda expression in lambda rule

This commit is contained in:
Nobuyoshi Nakada 2020-06-02 09:04:30 +09:00
parent 79a8ed0765
commit 27bef64862
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

31
parse.y
View file

@ -2912,17 +2912,7 @@ primary : literal
/*% %*/ /*% %*/
/*% ripper: method_add_block!($1, $2) %*/ /*% ripper: method_add_block!($1, $2) %*/
} }
| tLAMBDA | lambda
{
token_info_push(p, "->", &@1);
}
lambda
{
$$ = $3;
/*%%%*/
nd_set_first_loc($$, @1.beg_pos);
/*% %*/
}
| k_if expr_value then | k_if expr_value then
compstmt compstmt
if_tail if_tail
@ -3605,10 +3595,10 @@ bvar : tIDENTIFIER
} }
; ;
lambda : { lambda : tLAMBDA
$<vars>$ = dyna_push(p);
}
{ {
token_info_push(p, "->", &@1);
$<vars>1 = dyna_push(p);
$<num>$ = p->lex.lpar_beg; $<num>$ = p->lex.lpar_beg;
p->lex.lpar_beg = p->lex.paren_nest; p->lex.lpar_beg = p->lex.paren_nest;
} }
@ -3636,6 +3626,7 @@ lambda : {
$$ = NEW_LAMBDA($5, $7, &loc); $$ = NEW_LAMBDA($5, $7, &loc);
nd_set_line($$->nd_body, @7.end_pos.lineno); nd_set_line($$->nd_body, @7.end_pos.lineno);
nd_set_line($$, @5.end_pos.lineno); nd_set_line($$, @5.end_pos.lineno);
nd_set_first_loc($$, @1.beg_pos);
} }
/*% %*/ /*% %*/
/*% ripper: lambda!($5, $7) %*/ /*% ripper: lambda!($5, $7) %*/
@ -4347,17 +4338,7 @@ p_primitive : literal
/*% %*/ /*% %*/
/*% ripper: var_ref!($1) %*/ /*% ripper: var_ref!($1) %*/
} }
| tLAMBDA | lambda
{
token_info_push(p, "->", &@1);
}
lambda
{
$$ = $3;
/*%%%*/
nd_set_first_loc($$, @1.beg_pos);
/*% %*/
}
; ;
p_variable : tIDENTIFIER p_variable : tIDENTIFIER