summaryrefslogtreecommitdiff
path: root/parse.y
AgeCommit message (Collapse)Author
2025-12-30[Bug #21784] Fix the Proc#source_location start_column for stabby lambdasBenoit Daloze
* 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.
2025-12-19Terminate `args_tail_basic` rule with a semicolonyui-knk
Semicolon is optional however it clarifies the end of the rule.
2025-12-14Adjust indents [ci skip]Nobuyoshi Nakada
2025-12-12Binding#implicit_parameters, etc. support the implicit "it" parameterYusuke Endoh
[Bug #21049]
2025-12-11[Bug #21712] Allow `.()` call for command with blockyui-knk
This commit allows codes like `a b do end.()` and `a b do end&.()`.
2025-12-09Remove needless `ruby2_keywords` field from `struct rb_args_info`yui-knk
`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`.
2025-12-09Remove `FORWARD_ARGS_WITH_RUBY2_KEYWORDS` checkyui-knk
Because `FORWARD_ARGS_WITH_RUBY2_KEYWORDS` definition was removed by 4f77d8d3289ece0e3537d9273a5c745120bff59a.
2025-12-04Remove needless parse.y `new_nil` macroyui-knk
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.
2025-12-04Remove needless parse.y `value_expr` macroyui-knk
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.
2025-12-03Check and raise semantics errors on nested variables captures in patternsyui-knk
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 ```
2025-11-14[Feature #21572] Syntax error at capture in alternation patternNobuyoshi Nakada
Should fail even with `-c` option.
2025-11-14Skip null check for `brace_block`yui-knk
`brace_block` is `'{' brace_body '}'` or `k_do do_body k_end`. Both of them are not null so no need to check `$5`.
2025-09-21Rename mlhs rule to mlhs_items for clarity in parse.yydah
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
2025-09-13* adjust indents. [ci skip]Nobuyoshi Nakada
2025-09-13[Feature #20925] Support leading logical operatorsNobuyoshi Nakada
2025-09-13[Bug #17398] Allow `private def hello = puts "Hello"`yui-knk
2025-08-30Add NODE SCLASS locationsS-H-GAMELINKS
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" ```
2025-08-28Make `RubyVM::AST.of` return a parent node of NODE_SCOPEYusuke Endoh
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].
2025-08-11Add NODE IN locationsS-H-GAMELINKS
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" ```
2025-08-07Add MODULE NODE locationsS-H-GAMELINKS
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 ```
2025-07-24Add DEFINED NODE locationsS-H-GAMELINKS
Add keyword_defined locations to struct RNode_DEFINED
2025-07-16Make `defined? (x;)` return `expression` when using parse.y parserS-H-GAMELINKS
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)` .
2025-06-15Implement COLON3 NODE locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11987
2025-06-15Implement COLON2 NODE locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11987
2025-06-05[Bug #21381] Refine error messages for `it` and numbered parametersNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13522
2025-04-15Rename `f_optarg` to `f_opt_arg` for consistency in parser rulesydah
Notes: Merged: https://github.com/ruby/ruby/pull/13114
2025-04-14Use call_op2 instead of call_op and tCOLON2ydah
Notes: Merged: https://github.com/ruby/ruby/pull/13113
2025-04-14Use user defined parameterizing rules `range_expr`ydah
Notes: Merged: https://github.com/ruby/ruby/pull/13111
2025-04-14Add a new non-terminal symbol `ternary` to tidy upydah
Notes: Merged: https://github.com/ruby/ruby/pull/13110
2025-04-14Refactor assignment rules to remove unnecessary lhs parameterydah
Notes: Merged: https://github.com/ruby/ruby/pull/13109
2025-04-13Change the indent after lhs in generation rules from spaces to tabsydah
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
2025-03-29[Bug #21202] Fix wrong token concat while tokenizing nested unterminated ↵tomoya ishida
heredoc (#13000) Notes: Merged-By: tompng <tomoyapenguin@gmail.com>
2025-03-29Adjust indentation for user defined parameterized ruleydah
This PR just fixing indentation. Notes: Merged: https://github.com/ruby/ruby/pull/13010
2025-03-20[Bug #21026] no singleton method on pseudo variable literalNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12925
2025-03-17[Bug #21186] multibyte char literal should be a single letter wordNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12946
2025-03-14Organize block_param_def by defining opt_block_param for non-terminal symbolsydah
Notes: Merged: https://github.com/ruby/ruby/pull/12932
2025-03-14Refactor parse.y to replace tIDENTIFIER and tCONSTANT with ident_or_const ↵ydah
inline rules Notes: Merged: https://github.com/ruby/ruby/pull/12929
2025-03-14Use user defined parameterizing rules `args_tail_basic`ydah
Notes: Merged: https://github.com/ruby/ruby/pull/12928
2025-03-09Merge the `new_yield` method into the `rb_node_yield_new` methodydah
Notes: Merged: https://github.com/ruby/ruby/pull/12888
2025-03-09Refactor parser rules to remove inline_operationydah
Notes: Merged: https://github.com/ruby/ruby/pull/12886
2025-03-08Remove redundant semantic action in bvar ruleydah
Notes: Merged: https://github.com/ruby/ruby/pull/12883
2025-03-08Implement CLASS NODE locationsydah
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 ```
2025-03-03Implement POSTEXE NODE locationsydah
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) = "}" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ```
2025-03-02Use user defined parameterizing rules `mlhs`ydah
Notes: Merged: https://github.com/ruby/ruby/pull/12836
2025-03-02Change superclass rhs to use noneydah
Notes: Merged: https://github.com/ruby/ruby/pull/12835
2025-02-25s/TERMINTOR/TERMINATOR/ydah
Notes: Merged: https://github.com/ruby/ruby/pull/12800
2025-02-24[Bug #21153] Add missing op-assign to top const in `command_asgn`Nobuyoshi Nakada
It was defined in `arg` only; moved that pattern to `op_asgn` rule to share it with `command_asgn`.
2025-02-24Merge NODE_LINE and NODE_ENCODING cases in cond0 functionS-H-GAMELINKS
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
2025-01-21Remove unnecessary assignments to local variables in `f_arg_asgn`ydah
Local variables are not reassigned and are not needed. Notes: Merged: https://github.com/ruby/ruby/pull/12054
2025-01-21Remove unnecessary assignments to local variables in `strings`ydah
Local variables are not reassigned and are not needed. Notes: Merged: https://github.com/ruby/ruby/pull/12054