summaryrefslogtreecommitdiff
path: root/parse.y
AgeCommit message (Collapse)Author
2025-03-20[Bug #21186] multibyte char literal should be a single letter wordNobuyoshi Nakada
[Backport #21186]
2025-02-25[Bug #21153] Add missing op-assign to top const in `command_asgn`Nobuyoshi Nakada
It was defined in `arg` only; add that pattern to `command_asgn` as well.
2025-02-13merge revision(s) fb18bb183c24ca82b8f114ed090d62bd69b5df84: [Backport #20989]Takashi Kokubun
[Bug #20989] Ripper: Pass `compile_error` 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.
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
2024-09-30Use Named Referenceydah
Notes: Merged: https://github.com/ruby/ruby/pull/11673
2024-09-30Implement SPLAT NODE keyword locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11673
2024-09-28Allow dot3 in defs singletontompng
Notes: Merged: https://github.com/ruby/ruby/pull/11716
2024-09-28Implement OP_ASGN2 NODE locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11702
2024-09-28Remove on `RSTRING_END` dependency from parserNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11713
2024-09-27Reduce creating `rb_parser_string_t` repeatedly for literals.Nobuyoshi Nakada
Since #11698, `parser_str_new` makes `rb_parser_string_t` and `VALUE` but discards the former, and then `STR_NEW3` makes the same thing again. Notes: Merged: https://github.com/ruby/ruby/pull/11710
2024-09-27Add wrapper macros of `rb_parser_str_buf_cat`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11710
2024-09-27Reduce `is_ascii_string` function dependency for parserS-H-GAMELINKS
Changed to use `rb_parser_is_ascii_string` function instead of `is_ascii_string` function Notes: Merged: https://github.com/ruby/ruby/pull/11698
2024-09-27Implement OP_ASGN1 NODE locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11701
2024-09-26Fold rules [ci skip]Nobuyoshi Nakada
2024-09-25Fix memory leak in Ripper for indented heredocsPeter Zhu
The allocated parser string is never freed, which causes a memory leak. The following code leaks memory: Ripper.sexp_raw(DATA.read) __END__ <<~EOF a #{1} a EOF Notes: Merged: https://github.com/ruby/ruby/pull/11669
2024-09-25Implement BLOCK_PASS NODE keyword locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11663
2024-09-25Implement RETURN NODE keyword locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11589
2024-09-23Implement CASE3 NODE keyword locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11661
2024-09-23Implement CASE2 NODE keyword locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11661
2024-09-23Implement CASE NODE keyword locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11661
2024-09-22Reuse dedent_string function in rb_ruby_ripper_dedent_string functionS-H-GAMELINKS
This change is reduce Ruby C API dependency for Universal Parser. Reuse dedent_string functions in rb_ruby_ripper_dedent_string functions and remove dependencies on rb_str_modify and rb_str_set_len from the parser. Notes: Merged: https://github.com/ruby/ruby/pull/11658
2024-09-18Raise a compile error for break/next/redo inside eval in cases where it is ↵Jeremy Evans
optimized away In cases where break/next/redo are not valid syntax, they should raise a SyntaxError even if inside a conditional block that is optimized away. Fixes [Bug #20597] Co-authored-by: Kevin Newton <kddnewton@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/11099 Merged-By: jeremyevans <code@jeremyevans.net>
2024-09-11Fix issue with super and forwarding arguments in prism_compile.cLuke Gruber
Fixes [Bug #20720] Notes: Merged: https://github.com/ruby/ruby/pull/11565
2024-09-11Implement BREAK, NEXT and REDO NODE locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11584
2024-09-11Implement WHILE and UNTIL NODE locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11579
2024-09-09Implement WHEN NODE locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11553
2024-09-05Implement AND/OR NODE operator locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11543
2024-09-04Implement VALIAS NODE keyword locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11531
2024-09-03Implement ALIAS NODE keyword locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11530
2024-09-03Implement UNDEF NODE keyword locationsydah
Notes: Merged: https://github.com/ruby/ruby/pull/11523
2024-09-03[Bug #20695] Do not create needless string object in parseryui-knk
`set_parser_s_value` does nothing in parser therefore no need to create string object in parser `set_yylval_node`. # Object allocation Run `ruby benchmarks/lobsters/benchmark.rb` with the patch ```diff diff --git a/benchmarks/lobsters/benchmark.rb b/benchmarks/lobsters/benchmark.rb index 240c50c..6cdd0ac 100644 --- a/benchmarks/lobsters/benchmark.rb +++ b/benchmarks/lobsters/benchmark.rb @@ -7,6 +7,8 @@ Dir.chdir __dir__ use_gemfile require_relative 'config/environment' +printf "allocated_after_load=%d\n", GC.stat(:total_allocated_objects) +exit require_relative "route_generator" # For an in-mem DB, we need to load all data on every boot ``` ## Before ``` ruby 3.4.0dev (2024-08-31T18:30:25Z master d6fc8f3d57) [arm64-darwin21] ... allocated_after_load=2143519 ``` ## After ``` ruby 3.4.0dev (2024-09-01T00:40:04Z fix_bugs_20695 d1bae52f75) [arm64-darwin21] ... allocated_after_load=1579662 ``` ## Ruby 3.3.0 for reference ``` ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin21] ... allocated_after_load=1732702 ``` Notes: Merged: https://github.com/ruby/ruby/pull/11522
2024-08-25[Bug #20680] `ensure` block is always void contextNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11451
2024-08-20Make same structures sameNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11411
2024-08-07Fix leak of token_info when Ripper#warn jumpsPeter Zhu
For example, the following code leaks: class MyRipper < Ripper def initialize(src, &blk) super(src) @blk = blk end def warn(msg, *args) = @blk.call(msg) end $VERBOSE = true def call_parse = MyRipper.new("if true\n end\n") { |msg| return msg }.parse 10.times do 500_000.times do call_parse end puts `ps -o rss= -p #{$$}` end Before: 37536 53744 70064 86448 102576 119120 135248 151216 167744 183824 After: 19280 19696 19728 20336 20448 21408 21616 21616 21824 21840 Notes: Merged: https://github.com/ruby/ruby/pull/11289
2024-08-06Fix leak in warning of duplicate keys when Ripper#warn jumpsPeter Zhu
For example, the following code leaks: class MyRipper < Ripper def initialize(src, &blk) super(src) @blk = blk end def warn(msg, *args) = @blk.call(msg) end $VERBOSE = true def call_parse = MyRipper.new("if true\n end\n") { |msg| return msg }.parse 10.times do 500_000.times do call_parse end puts `ps -o rss= -p #{$$}` end Before: 34832 51952 69760 88048 105344 123040 141152 159152 176656 194272 After: 18400 20256 20272 20272 20272 20304 20368 20368 20368 20400 Notes: Merged: https://github.com/ruby/ruby/pull/11288
2024-08-02Refactor to use `tokenize_ident` instead of `TOK_INTERN` and `set_yylval_name`yui-knk
Notes: Merged: https://github.com/ruby/ruby/pull/11294
2024-07-31Fix leak of AST when Ripper#compile_error jumpsPeter Zhu
For example, the following script leaks: class MyRipper < Ripper def initialize(src, &blk) super(src) @blk = blk end def compile_error(msg) = @blk.call(msg) end def call_parse = MyRipper.new("/") { |msg| return msg }.parse 10.times do 100_000.times do call_parse end puts `ps -o rss= -p #{$$}` end Before: 93952 169040 244224 318784 394432 468224 544048 618560 693776 768384 After: 19776 19776 20352 20880 20912 21408 21328 21152 21472 20944 Notes: Merged: https://github.com/ruby/ruby/pull/11287
2024-07-26Change RESBODY Node structureyui-knk
Extracrt exception variable into `nd_exc_var` field to keep the original grammar structure. For example: ``` begin rescue Error => e1 end ``` Before: ``` @ NODE_RESBODY (id: 8, line: 2, location: (2,0)-(2,18)) +- nd_args: | @ NODE_LIST (id: 2, line: 2, location: (2,7)-(2,12)) | +- as.nd_alen: 1 | +- nd_head: | | @ NODE_CONST (id: 1, line: 2, location: (2,7)-(2,12)) | | +- nd_vid: :Error | +- nd_next: | (null node) +- nd_body: | @ NODE_BLOCK (id: 6, line: 2, location: (2,13)-(2,18)) | +- nd_head (1): | | @ NODE_LASGN (id: 3, line: 2, location: (2,13)-(2,18)) | | +- nd_vid: :e1 | | +- nd_value: | | @ NODE_ERRINFO (id: 5, line: 2, location: (2,13)-(2,18)) | +- nd_head (2): | @ NODE_BEGIN (id: 4, line: 2, location: (2,18)-(2,18)) | +- nd_body: | (null node) +- nd_next: (null node) ``` After: ``` @ NODE_RESBODY (id: 6, line: 2, location: (2,0)-(2,18)) +- nd_args: | @ NODE_LIST (id: 2, line: 2, location: (2,7)-(2,12)) | +- as.nd_alen: 1 | +- nd_head: | | @ NODE_CONST (id: 1, line: 2, location: (2,7)-(2,12)) | | +- nd_vid: :Error | +- nd_next: | (null node) +- nd_exc_var: | @ NODE_LASGN (id: 3, line: 2, location: (2,13)-(2,18)) | +- nd_vid: :e1 | +- nd_value: | @ NODE_ERRINFO (id: 5, line: 2, location: (2,13)-(2,18)) +- nd_body: | @ NODE_BEGIN (id: 4, line: 2, location: (2,18)-(2,18)) | +- nd_body: | (null node) +- nd_next: (null node) ``` Notes: Merged: https://github.com/ruby/ruby/pull/11243
2024-07-24[Bug #20647] Disallow `return` directly within a singleton classNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11234