summaryrefslogtreecommitdiff
path: root/parse.y
AgeCommit message (Collapse)Author
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
2025-01-09[Feature #6012] Extend `source_location` for end position and columnsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12539
2025-01-09Refactor for loop handling to simplify do keyword location assignmentydah
2025-01-09Use Named Referenceydah
2025-01-09Implement FOR 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 "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" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ```
2025-01-09Refactor `parse_isalnum` and `parse_isxdigit` to use macroydah
Notes: Merged: https://github.com/ruby/ruby/pull/11780
2025-01-08Remove unnecessary semantic actionsydah
If you don’t specify an action for a rule, Lrama supplies a default: `$$ = $1`.
2025-01-07Remove unused token definitions for `tRPAREN` in Ripper and parser filesydah
Notes: Merged: https://github.com/ruby/ruby/pull/12488
2025-01-05[Bug #21004] Fix memory leak with "it" in parse.yPeter Zhu
Parsing `-> do it end` in parse.y leaks memory. We can see this in the Valgrind output: 56 bytes in 1 blocks are definitely lost in loss record 1 of 6 at 0x484E0DC: calloc (vg_replace_malloc.c:1675) by 0x188970: calloc1 (default.c:1472) by 0x188970: rb_gc_impl_calloc (default.c:8208) by 0x188970: ruby_xcalloc_body (gc.c:4598) by 0x18B8BC: ruby_xcalloc (gc.c:4592) by 0x21DCCA70: new_locations_lambda_body (ripper.y:12844) by 0x21DCCA70: ripper_yyparse (ripper.y:5194) by 0x21DDA521: rb_ruby_ripper_parse0 (ripper.y:15798) Notes: Merged: https://github.com/ruby/ruby/pull/12508
2025-01-05Remove unused loc in rb_locations_lambda_body_tPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/12508
2025-01-04Implement DOT3 NODE locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11986
2025-01-04Implement DOT2 NODE locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11986
2025-01-04Use user defined parameterizing rules `compstmt(stmts)`ydah
Notes: Merged: https://github.com/ruby/ruby/pull/11652
2025-01-04Use user defined parameterizing rules `op_asgn(rhs)`ydah
Notes: Merged: https://github.com/ruby/ruby/pull/12494
2025-01-04Use user defined parameterizing rules `def_endless_method(bodystmt)`ydah
Notes: Merged: https://github.com/ruby/ruby/pull/12494
2025-01-04Use user defined parameterizing rules `asgn(lhs, rhs)`ydah
Notes: Merged: https://github.com/ruby/ruby/pull/12494
2025-01-04Use `p_primitive_value`ydah
Notes: Merged: https://github.com/ruby/ruby/pull/11889
2025-01-04Use `command_call_value`ydah
Notes: Merged: https://github.com/ruby/ruby/pull/11889
2025-01-04Use user defined parameterizing rules `value_expr`ydah
Notes: Merged: https://github.com/ruby/ruby/pull/11889
2025-01-04Use user defined parameterizing rules `f_kw(value)`ydah
Notes: Merged: https://github.com/ruby/ruby/pull/11674
2025-01-04Implement REGX 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 '/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" ```
2025-01-04Implement LAMBDA 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 "-> (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) ```
2025-01-04Implement YIELD 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 '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" ```
2025-01-04Implement EVSTR 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 '"#{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) = "\"" ```
2025-01-03Implement SUPER NODE locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11712
2025-01-03Refactor parse.y to replace `tIDENTIFIER` and `tCONSTANT` with ↵ydah
`ident_or_const` inline rules Notes: Merged: https://github.com/ruby/ruby/pull/11782
2025-01-03Use Named Reference for RHS of `def_name`ydah
Notes: Merged: https://github.com/ruby/ruby/pull/11677
2025-01-03Use callee side tag specification of parameterizing rulesydah
Notes: Merged: https://github.com/ruby/ruby/pull/11676
2025-01-03Change the reference to the RHS in the Parameterizing rules action to a ↵ydah
Named Reference Notes: Merged: https://github.com/ruby/ruby/pull/11651
2025-01-03Implement IF 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 -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" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ```
2025-01-03[Bug #20504] Move dynamic regexp concatenation to iseq compilerNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12483
2025-01-02Rename to backref_withS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/11865
2025-01-02Introduce backref_with_rhs parameterizing rulesS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/11865
2025-01-02Introduce inline_operation ruleS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/10773
2024-12-28[Bug #20990] Reject escaped multibyte char with control/meta prefixNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12485
2024-12-28Ripper: Fix duplicate regexp errorsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12482
2024-12-28[Bug #20989] Ripper: Pass `compile_error`Nobuyoshi Nakada
For the universal parser, `rb_parser_reg_fragment_check` function is shared between the parser and ripper. However `parser_params` struct is partially different, and `compile_error` function depends on that part indirectly. Notes: Merged: https://github.com/ruby/ruby/pull/12482
2024-12-23Revert "[Bug #20965] Define `it` like an ordinary argument" (#12418)Takashi Kokubun
Revert "[Bug #20965] Define `it` like an ordinary argument (#12398)" Reverts ruby/ruby#12398 as per https://bugs.ruby-lang.org/issues/20970#note-6 and https://bugs.ruby-lang.org/issues/20965#note-7. We need more time to design the intended behavior, and it's too late for Ruby 3.4. Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2024-12-19[Bug #20969] Pass `assignable` from ripperNobuyoshi Nakada
For the universal parser, `rb_reg_named_capture_assign_iter_impl` function is shared between the parser and ripper. However `parser_params` struct is partially different, and `assignable` function depends on that part indirectly. Notes: Merged: https://github.com/ruby/ruby/pull/12400
2024-12-18[Bug #20965] Define `it` like an ordinary argument (#12398)Nobuyoshi Nakada
Also fixes [Bug #20955] Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2024-12-10Remove unused macros from parse.yydah
Notes: Merged: https://github.com/ruby/ruby/pull/11781
2024-12-10Remove minimum Bison version requirement from parse.yydah
How about removing `%require “version”` since it is a definition to specify the minimum version of Bison and is not needed now that we have completely moved to Lrama? see: https://www.gnu.org/software/bison/manual/html_node/Require-Decl.html
2024-10-25Introduce inline_primary ruleS.H.
Introduce inline_primary rule to merge the same BNF pattern Notes: Merged: https://github.com/ruby/ruby/pull/11881 Merged-By: nobu <nobu@ruby-lang.org>
2024-10-09[Bug #20789] Fix an invalid syntax error when `->a=1...{}`ydah
https://bugs.ruby-lang.org/issues/20789 Notes: Merged: https://github.com/ruby/ruby/pull/11850
2024-10-05Merge `rb_parser_enc_compatible_latter` into `rb_parser_enc_compatible`Nobuyoshi Nakada
2024-10-05Parser string encoding is always ASCII-compatibleNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11806
2024-10-05[Bug #20784] Fix incomplete character syntax followed by EOFtompng
Notes: Merged: https://github.com/ruby/ruby/pull/11805
2024-10-01Use user defined inline rules `user_or_keyword_variable`ydah
Notes: Merged: https://github.com/ruby/ruby/pull/11752
2024-10-01[Bug #20764] Refactor argument forwarding in lambdaNobuyoshi Nakada
Reject argument forwarding in lambda: - without parentheses - after optional argument(s) Notes: Merged: https://github.com/ruby/ruby/pull/11751