Implement CLASS 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 "class A < B; end"
@ ProgramNode (location: (1,0)-(1,16))
+-- locals: []
+-- statements:
    @ StatementsNode (location: (1,0)-(1,16))
    +-- body: (length: 1)
        +-- @ ClassNode (location: (1,0)-(1,16))
            +-- locals: []
            +-- class_keyword_loc: (1,0)-(1,5) = "class"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- constant_path:
            |   @ ConstantReadNode (location: (1,6)-(1,7))
            |   +-- name: :A
            +-- inheritance_operator_loc: (1,8)-(1,9) = "<"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- superclass:
            |   @ ConstantReadNode (location: (1,10)-(1,11))
            |   +-- name: :B
            +-- body: nil
            +-- end_keyword_loc: (1,13)-(1,16) = "end"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- name: :A
```
This commit is contained in:
ydah 2024-11-03 23:52:50 +09:00 committed by Yudai Takada
parent 98790faae3
commit eae0fe37c0
5 changed files with 33 additions and 6 deletions

View file

@ -891,6 +891,9 @@ typedef struct RNode_CLASS {
struct RNode *nd_cpath;
struct RNode *nd_body;
struct RNode *nd_super;
rb_code_location_t class_keyword_loc;
rb_code_location_t inheritance_operator_loc;
rb_code_location_t end_keyword_loc;
} rb_node_class_t;
typedef struct RNode_MODULE {