summaryrefslogtreecommitdiff
path: root/ast.c
diff options
context:
space:
mode:
authorydah <[email protected]>2024-11-02 17:21:51 +0900
committerYudai Takada <[email protected]>2025-01-04 13:52:35 +0900
commitfa2517451ec265d5b273e864bc750a1b9ba2957f (patch)
treebf2d88ec9a7e0d2deee331acba938ce5573c03d2 /ast.c
parent607b1b3d7628b1f94f086ce1dfe67789179cf906 (diff)
Implement LAMBDA NODE locations
The following Location information has been added This is the information required for parse.y to be a universal parser: ``` ❯ ruby --parser=prism --dump=parsetree -e "-> (a, b) do foo end" @ ProgramNode (location: (1,0)-(1,20)) +-- locals: [] +-- statements: @ StatementsNode (location: (1,0)-(1,20)) +-- body: (length: 1) +-- @ LambdaNode (location: (1,0)-(1,20)) +-- locals: [:a, :b] +-- operator_loc: (1,0)-(1,2) = "->" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +-- opening_loc: (1,10)-(1,12) = "do" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +-- closing_loc: (1,17)-(1,20) = "end" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ : (snip) ```
Diffstat (limited to 'ast.c')
-rw-r--r--ast.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ast.c b/ast.c
index 861785871a..45559b6fd1 100644
--- a/ast.c
+++ b/ast.c
@@ -812,6 +812,12 @@ node_locations(VALUE ast_value, const NODE *node)
location_new(nd_code_loc(node)),
location_new(&RNODE_EVSTR(node)->opening_loc),
location_new(&RNODE_EVSTR(node)->closing_loc));
+ case NODE_LAMBDA:
+ return rb_ary_new_from_args(4,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_LAMBDA(node)->operator_loc),
+ location_new(&RNODE_LAMBDA(node)->opening_loc),
+ location_new(&RNODE_LAMBDA(node)->closing_loc));
case NODE_IF:
return rb_ary_new_from_args(4,
location_new(nd_code_loc(node)),