diff options
author | ydah <[email protected]> | 2024-11-05 14:13:29 +0900 |
---|---|---|
committer | Yudai Takada <[email protected]> | 2025-01-04 13:53:13 +0900 |
commit | 5fcc3ab534cb001a577a5c64381d3a31813344c9 (patch) | |
tree | 62687d0f66759fbfa458f6c5182f320a57f2fbf5 /node_dump.c | |
parent | fa2517451ec265d5b273e864bc750a1b9ba2957f (diff) |
Implement REGX 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 '/foo/'
@ ProgramNode (location: (1,0)-(1,5))
+-- locals: []
+-- statements:
@ StatementsNode (location: (1,0)-(1,5))
+-- body: (length: 1)
+-- @ RegularExpressionNode (location: (1,0)-(1,5))
+-- RegularExpressionFlags: forced_us_ascii_encoding
+-- opening_loc: (1,0)-(1,1) = "/"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- content_loc: (1,1)-(1,4) = "foo"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- closing_loc: (1,4)-(1,5) = "/"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- unescaped: "foo"
```
Diffstat (limited to 'node_dump.c')
-rw-r--r-- | node_dump.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/node_dump.c b/node_dump.c index 52c924a9d0..a585ff12fe 100644 --- a/node_dump.c +++ b/node_dump.c @@ -835,8 +835,11 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) ANN("regexp literal"); ANN("format: [string]"); ANN("example: /foo/"); - LAST_NODE; F_VALUE(string, rb_node_regx_string_val(node), "string"); + F_LOC(opening_loc, RNODE_REGX); + F_LOC(content_loc, RNODE_REGX); + LAST_NODE; + F_LOC(closing_loc, RNODE_REGX); return; case NODE_ONCE: |