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 /rubyparser.h | |
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 'rubyparser.h')
-rw-r--r-- | rubyparser.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/rubyparser.h b/rubyparser.h index cd1e88ff6c..2db250c27e 100644 --- a/rubyparser.h +++ b/rubyparser.h @@ -737,6 +737,9 @@ typedef struct RNode_REGX { /* also RNode_MATCH */ struct rb_parser_string *string; int options; + rb_code_location_t opening_loc; + rb_code_location_t content_loc; + rb_code_location_t closing_loc; } rb_node_regx_t, rb_node_match_t; typedef rb_node_dstr_t rb_node_dregx_t; |