| Age | Commit message (Collapse) | Author |
|
Semicolon is optional however it clarifies the end of the rule.
|
|
|
|
[Bug #21049]
|
|
This commit allows codes like `a b do end.()` and `a b do end&.()`.
|
|
`ruby2_keywords` is set only to be `0` in parse.y.
However `args->ruby2_keywords` is initialized with `0` by `MEMZERO`
in `rb_node_args_new` function and `body->param.flags.ruby2_keywords`
is initialized with `0` by `ZALLOC` in `rb_iseq_constant_body_alloc` function,
so `args->ruby2_keywords` does nothing for `body->param.flags.ruby2_keywords`.
|
|
Because `FORWARD_ARGS_WITH_RUBY2_KEYWORDS` definition was removed
by 4f77d8d3289ece0e3537d9273a5c745120bff59a.
|
|
In the past parse.y and ripper had different `new_nil` definition
so that `new_nil` returns `nil` for ripper.
```c
// parse.y
#define new_nil(loc) NEW_NIL(loc)
// ripper
#define new_nil(loc) Qnil
```
However Rearchitect Ripper (89cfc1520717257073012ec07105c551e4b8af7c)
removed `new_nil` definition for ripper then this commit removes
needless parse.y macro and uses `NEW_NIL` directly.
|
|
In the past parse.y and ripper had different `value_expr` definition
so that `value_expr` does nothing for ripper.
```c
// parse.y
#define value_expr(node) value_expr_gen(p, (node))
// ripper
#define value_expr(node) ((void)(node))
```
However Rearchitect Ripper (89cfc1520717257073012ec07105c551e4b8af7c)
removed `value_expr` definition for ripper then this commit removes
needless parse.y macro and uses `value_expr_gen` directly.
|
|
This commit makes these codes to be invalid.
```ruby
case 0
in [a] | 1
end
case 0
in { a: b } | 1
end
case 0
in [{ a: [{ b: [{ c: }] }] }] | 1
end
```
|
|
Should fail even with `-c` option.
|
|
`brace_block` is `'{' brace_body '}'` or `k_do do_body k_end`.
Both of them are not null so no need to check `$5`.
|
|
Since `mlhs` is already defined as a nonterminal as follows, using the same name as a parameterizing rule is a bit confusing, so rename the parameterizing rule.
https://github.com/ruby/ruby/blob/8d1c45978329bced97c003d9612b55f578c40a65/parse.y#L3648-L3654
|
|
|
|
|
|
|
|
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"
```
|
|
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
|
|
Follow up [Bug #21029].
Currently, `defined? (x;)` returns `expression` when using Prism parser.
See:
- https://github.com/ruby/ruby/pull/12949
- https://bugs.ruby-lang.org/issues/21029
However, `defined? (x;)` returns nil when using parse.y, as reported in bug ticket comment and test-all (when using parse.y parser) test result.
This change adds a context flag to track trailing semicolons in defined? scope.
When a trailing semicolon is detected within a defined? scope, the generated AST node is wrapped with NODE_BLOCK.
This change ensures consistent behavior with `defined? (;x)` .
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11987
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11987
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13522
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13114
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13113
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13111
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13110
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13109
|
|
Change the indent to match the characters used in other generation rules. This makes it easier to find lhs.
Notes:
Merged: https://github.com/ruby/ruby/pull/13082
|
|
heredoc (#13000)
Notes:
Merged-By: tompng <tomoyapenguin@gmail.com>
|
|
This PR just fixing indentation.
Notes:
Merged: https://github.com/ruby/ruby/pull/13010
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12925
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12946
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12932
|
|
inline rules
Notes:
Merged: https://github.com/ruby/ruby/pull/12929
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12928
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12888
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12886
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12883
|
|
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
```
|
|
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) = "}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12836
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12835
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12800
|
|
It was defined in `arg` only; moved that pattern to `op_asgn` rule to
share it with `command_asgn`.
|
|
NODE_LINE and NODE_ENCODING cases are used SWITCH_BY_COND_TYPE macro that is same to NODE_INTEGER and other cases.
NODE_LINE and NODE_ENCODING cases can be marge to NODE_INTEGER and other node cases.
Notes:
Merged: https://github.com/ruby/ruby/pull/12794
|
|
Local variables are not reassigned and are not needed.
Notes:
Merged: https://github.com/ruby/ruby/pull/12054
|
|
Local variables are not reassigned and are not needed.
Notes:
Merged: https://github.com/ruby/ruby/pull/12054
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12539
|