summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-02 09:04:30 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-02 09:06:49 +0900
commit27bef648629760ffeda569057ddef6fb3be64b9a (patch)
tree9f11ff7e99e2e5299f6690cea59d36dda69247f9
parent79a8ed07650dcbb36ec4b49a22596275e6c0fe23 (diff)
Include the entire lambda expression in lambda rule
-rw-r--r--parse.y31
1 files changed, 6 insertions, 25 deletions
diff --git a/parse.y b/parse.y
index 74cdd4a958..d2099e204c 100644
--- a/parse.y
+++ b/parse.y
@@ -2912,17 +2912,7 @@ primary : literal
/*% %*/
/*% ripper: method_add_block!($1, $2) %*/
}
- | tLAMBDA
- {
- token_info_push(p, "->", &@1);
- }
- lambda
- {
- $$ = $3;
- /*%%%*/
- nd_set_first_loc($$, @1.beg_pos);
- /*% %*/
- }
+ | lambda
| k_if expr_value then
compstmt
if_tail
@@ -3605,10 +3595,10 @@ bvar : tIDENTIFIER
}
;
-lambda : {
- $<vars>$ = dyna_push(p);
- }
+lambda : tLAMBDA
{
+ token_info_push(p, "->", &@1);
+ $<vars>1 = dyna_push(p);
$<num>$ = p->lex.lpar_beg;
p->lex.lpar_beg = p->lex.paren_nest;
}
@@ -3636,6 +3626,7 @@ lambda : {
$$ = NEW_LAMBDA($5, $7, &loc);
nd_set_line($$->nd_body, @7.end_pos.lineno);
nd_set_line($$, @5.end_pos.lineno);
+ nd_set_first_loc($$, @1.beg_pos);
}
/*% %*/
/*% ripper: lambda!($5, $7) %*/
@@ -4347,17 +4338,7 @@ p_primitive : literal
/*% %*/
/*% ripper: var_ref!($1) %*/
}
- | tLAMBDA
- {
- token_info_push(p, "->", &@1);
- }
- lambda
- {
- $$ = $3;
- /*%%%*/
- nd_set_first_loc($$, @1.beg_pos);
- /*% %*/
- }
+ | lambda
;
p_variable : tIDENTIFIER