| Age | Commit message (Collapse) | Author |
|
* Consistent with plain `blocks` and `for` blocks and methods
where the source_location covers their entire definition.
* Matches the documentation which mentions
"where the definition starts/ends".
* Partially reverts d357d50f0a74409446f4cccec78593373f5adf2f
which was a workaround to be compatible with parse.y.
|
|
|
|
Add locations to struct `RNode_SCLASS`.
memo:
```
@ ProgramNode (location: (1,0)-(1,18))
+-- locals: []
+-- statements:
@ StatementsNode (location: (1,0)-(1,18))
+-- body: (length: 1)
+-- @ SingletonClassNode (location: (1,0)-(1,18))
+-- locals: []
+-- class_keyword_loc: (1,0)-(1,5) = "class"
+-- operator_loc: (1,6)-(1,8) = "<<"
+-- expression:
| @ SelfNode (location: (1,9)-(1,13))
+-- body: nil
+-- end_keyword_loc: (1,15)-(1,18) = "end"
```
|
|
Previously, it was not possible to obtain a node of the callee's
`Thread::Backtrace::Location` for cases like "wrong number of
arguments" by using `RubyVM::AST.of`. This change allows that retrieval.
This is preparation for [Feature #21543].
|
|
This change makes `RubyVM::AST.of` and `.node_id_for_backtrace_location`
return a parent node of NODE_SCOPE (such as NODE_DEFN) instead of the
NODE_SCOPE node itself.
(In future, we may remove NODE_SCOPE, which is a bit hacky AST node.)
This is preparation for [Feature #21543].
|
|
Add locations to struct `RNode_IN`.
memo:
```bash
> ruby -e 'case 1; in 2 then 3; end' --parser=prism --dump=parsetree
@ ProgramNode (location: (1,0)-(1,24))
+-- locals: []
+-- statements:
@ StatementsNode (location: (1,0)-(1,24))
+-- body: (length: 1)
+-- @ CaseMatchNode (location: (1,0)-(1,24))
+-- predicate:
| @ IntegerNode (location: (1,5)-(1,6))
| +-- IntegerBaseFlags: decimal
| +-- value: 1
+-- conditions: (length: 1)
| +-- @ InNode (location: (1,8)-(1,19))
| +-- pattern:
| | @ IntegerNode (location: (1,11)-(1,12))
| | +-- IntegerBaseFlags: decimal
| | +-- value: 2
| +-- statements:
| | @ StatementsNode (location: (1,18)-(1,19))
| | +-- body: (length: 1)
| | +-- @ IntegerNode (location: (1,18)-(1,19))
| | +-- IntegerBaseFlags: decimal
| | +-- value: 3
| +-- in_loc: (1,8)-(1,10) = "in"
| +-- then_loc: (1,13)-(1,17) = "then"
+-- else_clause: nil
+-- case_keyword_loc: (1,0)-(1,4) = "case"
+-- end_keyword_loc: (1,21)-(1,24) = "end"
```
|
|
Add `keyword_module` amd `keyword_end` locations to struct `RNode_MODULE`.
memo:
```
>ruby --dump=parsetree -e 'module A end'
@ ProgramNode (location: (1,0)-(1,12))
+-- locals: []
+-- statements:
@ StatementsNode (location: (1,0)-(1,12))
+-- body: (length: 1)
+-- @ ModuleNode (location: (1,0)-(1,12))
+-- locals: []
+-- module_keyword_loc: (1,0)-(1,6) = "module"
+-- constant_path:
| @ ConstantReadNode (location: (1,7)-(1,8))
| +-- name: :A
+-- body: nil
+-- end_keyword_loc: (1,9)-(1,12) = "end"
+-- name: :A
```
|
|
|
|
Add keyword_defined locations to struct RNode_DEFINED
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11987
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11987
|
|
[Bug #21383]
The following script leaks memory:
10.times do
20_000.times do
eval("class C; yield; end")
rescue SyntaxError
end
puts `ps -o rss= -p #{$$}`
end
Before:
16464
25536
29424
35904
39552
44576
46736
51600
56096
59824
After:
13488
16160
18240
20528
19760
21808
21680
22272
22064
22336
Notes:
Merged: https://github.com/ruby/ruby/pull/13464
|
|
|
|
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
```
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12837
|
|
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) = "}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
|
|
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 "for a in b do end"
@ ProgramNode (location: (1,0)-(1,17))
+-- locals: [:a]
+-- statements:
@ StatementsNode (location: (1,0)-(1,17))
+-- body: (length: 1)
+-- @ ForNode (location: (1,0)-(1,17))
+-- index:
| @ LocalVariableTargetNode (location: (1,4)-(1,5))
| +-- name: :a
| +-- depth: 0
+-- collection:
| @ CallNode (location: (1,9)-(1,10))
| +-- CallNodeFlags: variable_call, ignore_visibility
| +-- receiver: nil
| +-- call_operator_loc: nil
| +-- name: :b
| +-- message_loc: (1,9)-(1,10) = "b"
| +-- opening_loc: nil
| +-- arguments: nil
| +-- closing_loc: nil
| +-- block: nil
+-- statements: nil
+-- for_keyword_loc: (1,0)-(1,3) = "for"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- in_keyword_loc: (1,6)-(1,8) = "in"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- do_keyword_loc: (1,11)-(1,13) = "do"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- end_keyword_loc: (1,14)-(1,17) = "end"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
|
|
There are warnings emitted from test_flip2_locations and test_flip3_locations.
This commit changes ast_parse to suppress all warnings.
warning: integer literal in flip-flop
warning: string literal in flip-flop
Notes:
Merged: https://github.com/ruby/ruby/pull/12509
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11986
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11986
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11986
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11986
|
|
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"
```
|
|
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 "-> (a, b) do foo end"
@ ProgramNode (location: (1,0)-(1,20))
+-- locals: []
+-- statements:
@ StatementsNode (location: (1,0)-(1,20))
+-- body: (length: 1)
+-- @ LambdaNode (location: (1,0)-(1,20))
+-- locals: [:a, :b]
+-- operator_loc: (1,0)-(1,2) = "->"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- opening_loc: (1,10)-(1,12) = "do"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- closing_loc: (1,17)-(1,20) = "end"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: (snip)
```
|
|
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"
```
|
|
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,8))
+-- locals: []
+-- statements:
@ StatementsNode (location: (1,0)-(1,8))
+-- body: (length: 1)
+-- @ InterpolatedStringNode (location: (1,0)-(1,8))
+-- InterpolatedStringNodeFlags: nil
+-- opening_loc: (1,0)-(1,1) = "\""
+-- parts: (length: 1)
| +-- @ EmbeddedStatementsNode (location: (1,1)-(1,7))
| +-- opening_loc: (1,1)-(1,3) = "\#{"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| +-- statements:
| | @ StatementsNode (location: (1,3)-(1,6))
| | +-- body: (length: 1)
| | +-- @ CallNode (location: (1,3)-(1,6))
| | +-- CallNodeFlags: variable_call, ignore_visibility
| | +-- receiver: nil
| | +-- call_operator_loc: nil
| | +-- name: :foo
| | +-- message_loc: (1,3)-(1,6) = "foo"
| | +-- opening_loc: nil
| | +-- arguments: nil
| | +-- closing_loc: nil
| | +-- block: nil
| +-- closing_loc: (1,6)-(1,7) = "}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- closing_loc: (1,7)-(1,8) = "\""
```
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11712
|
|
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 -y -e "if a; elsif b; else end"
@ ProgramNode (location: (1,0)-(1,23))
+-- locals: []
+-- statements:
@ StatementsNode (location: (1,0)-(1,23))
+-- body: (length: 1)
+-- @ IfNode (location: (1,0)-(1,23))
+-- if_keyword_loc: (1,0)-(1,2) = "if"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- predicate:
| @ CallNode (location: (1,3)-(1,4))
| +-- CallNodeFlags: variable_call, ignore_visibility
| +-- receiver: nil
| +-- call_operator_loc: nil
| +-- name: :a
| +-- message_loc: (1,3)-(1,4) = "a"
| +-- opening_loc: nil
| +-- arguments: nil
| +-- closing_loc: nil
| +-- block: nil
+-- then_keyword_loc: nil
^^^^^^^^^^^^^^^^^^^^^^^^^
+-- statements: nil
+-- subsequent:
| @ IfNode (location: (1,6)-(1,23))
| +-- if_keyword_loc: (1,6)-(1,11) = "elsif"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| +-- predicate:
| | @ CallNode (location: (1,12)-(1,13))
| | +-- CallNodeFlags: variable_call, ignore_visibility
| | +-- receiver: nil
| | +-- call_operator_loc: nil
| | +-- name: :b
| | +-- message_loc: (1,12)-(1,13) = "b"
| | +-- opening_loc: nil
| | +-- arguments: nil
| | +-- closing_loc: nil
| | +-- block: nil
| +-- then_keyword_loc: nil
^^^^^^^^^^^^^^^^^^^^^^^^^
| +-- statements: nil
| +-- subsequent:
| | @ ElseNode (location: (1,15)-(1,23))
| | +-- else_keyword_loc: (1,15)-(1,19) = "else"
| | +-- statements: nil
| | +-- end_keyword_loc: (1,20)-(1,23) = "end"
| +-- end_keyword_loc: (1,20)-(1,23) = "end"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- end_keyword_loc: (1,20)-(1,23) = "end"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/10924
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11673
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11702
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11701
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11663
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11589
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11661
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11661
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11661
|
|
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11497
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11584
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11579
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11553
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11543
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11531
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11530
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11523
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11451
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11227
|
|
This commit introduce `RubyVM::AbstractSyntaxTree::Node#locations` method
and `RubyVM::AbstractSyntaxTree::Location` class.
Ruby AST node will hold multiple locations information.
`RubyVM::AbstractSyntaxTree::Node#locations` provides a way to access
these locations information.
`RubyVM::AbstractSyntaxTree::Location` is a class which holds these location information:
* `#first_lineno`
* `#first_column`
* `#last_lineno`
* `#last_column`
Notes:
Merged: https://github.com/ruby/ruby/pull/11226
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11201
|