diff options
author | ydah <[email protected]> | 2024-11-02 17:21:51 +0900 |
---|---|---|
committer | Yudai Takada <[email protected]> | 2025-01-04 13:52:35 +0900 |
commit | fa2517451ec265d5b273e864bc750a1b9ba2957f () | |
tree | bf2d88ec9a7e0d2deee331acba938ce5573c03d2 /ast.c | |
parent | 607b1b3d7628b1f94f086ce1dfe67789179cf906 (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) ```
-rw-r--r-- | ast.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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_IF: return rb_ary_new_from_args(4, location_new(nd_code_loc(node)), |