mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Implement YIELD 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 'def foo; yield end' @ ProgramNode (location: (1,0)-(1,18)) +-- locals: [] +-- statements: @ StatementsNode (location: (1,0)-(1,18)) +-- body: (length: 1) +-- @ DefNode (location: (1,0)-(1,18)) +-- name: :foo +-- name_loc: (1,4)-(1,7) = "foo" +-- receiver: nil +-- parameters: nil +-- body: | @ StatementsNode (location: (1,9)-(1,14)) | +-- body: (length: 1) | +-- @ YieldNode (location: (1,9)-(1,14)) | +-- keyword_loc: (1,9)-(1,14) = "yield" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | +-- lparen_loc: nil ^^^^^^^^^^^^^^^^^^^ | +-- arguments: nil | +-- rparen_loc: nil ^^^^^^^^^^^^^^^^^^^ +-- locals: [] +-- def_keyword_loc: (1,0)-(1,3) = "def" +-- operator_loc: nil +-- lparen_loc: nil +-- rparen_loc: nil +-- equal_loc: nil +-- end_keyword_loc: (1,15)-(1,18) = "end" ```
This commit is contained in:
parent
4c19201142
commit
607b1b3d76
5 changed files with 40 additions and 11 deletions
|
@ -593,6 +593,9 @@ typedef struct RNode_YIELD {
|
|||
NODE node;
|
||||
|
||||
struct RNode *nd_head;
|
||||
rb_code_location_t keyword_loc;
|
||||
rb_code_location_t lparen_loc;
|
||||
rb_code_location_t rparen_loc;
|
||||
} rb_node_yield_t;
|
||||
|
||||
typedef struct RNode_LVAR {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue