diff options
author | ydah <[email protected]> | 2024-11-02 15:46:49 +0900 |
---|---|---|
committer | Yudai Takada <[email protected]> | 2025-03-03 11:17:14 +0900 |
commit | a47e686cb6195dbd1266229d6e8d6bb17207c311 (patch) | |
tree | a8be0db1a50f1b41da76ebb3ae343bf5ab25541a /ast.c | |
parent | 617e8608b2cff8be1d063c2f47ab425cda839d58 (diff) |
Implement POSTEXE 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 "END { }"
@ ProgramNode (location: (1,0)-(1,8))
+-- locals: []
+-- statements:
@ StatementsNode (location: (1,0)-(1,8))
+-- body: (length: 1)
+-- @ PostExecutionNode (location: (1,0)-(1,8))
+-- statements: nil
+-- keyword_loc: (1,0)-(1,3) = "END"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- opening_loc: (1,4)-(1,5) = "{"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- closing_loc: (1,7)-(1,8) = "}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
Diffstat (limited to 'ast.c')
-rw-r--r-- | ast.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -868,6 +868,12 @@ node_locations(VALUE ast_value, const NODE *node) location_new(&RNODE_OP_ASGN2(node)->call_operator_loc), location_new(&RNODE_OP_ASGN2(node)->message_loc), location_new(&RNODE_OP_ASGN2(node)->binary_operator_loc)); + case NODE_POSTEXE: + return rb_ary_new_from_args(4, + location_new(nd_code_loc(node)), + location_new(&RNODE_POSTEXE(node)->keyword_loc), + location_new(&RNODE_POSTEXE(node)->opening_loc), + location_new(&RNODE_POSTEXE(node)->closing_loc)); case NODE_REDO: return rb_ary_new_from_args(2, location_new(nd_code_loc(node)), |