ydah
fd2f66e3c0
Use Named Reference for RHS of def_name
2025-01-03 21:21:52 +09:00
ydah
aa892378a1
Use callee side tag specification of parameterizing rules
2025-01-03 21:20:15 +09:00
ydah
1e2ed31cc2
Change the reference to the RHS in the Parameterizing rules action to a Named Reference
2025-01-03 21:19:41 +09:00
ydah
0643f08187
Implement IF NODE locations
...
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 20:34:19 +09:00
Nobuyoshi Nakada
6bbb470dc7
[Bug #20504 ] Move dynamic regexp concatenation to iseq compiler
2025-01-03 10:25:15 +09:00
S-H-GAMELINKS
3eebc81041
Rename to backref_with
2025-01-02 17:11:32 +09:00
S-H-GAMELINKS
1686c6b787
Introduce backref_with_rhs parameterizing rules
2025-01-02 17:11:32 +09:00
S-H-GAMELINKS
03b37fb342
Introduce inline_operation rule
2025-01-02 17:10:31 +09:00
Nobuyoshi Nakada
e4ec2128ae
[Bug #20990 ] Reject escaped multibyte char with control/meta prefix
2024-12-28 18:40:37 +09:00
Nobuyoshi Nakada
0ccc7657f3
Ripper: Fix duplicate regexp errors
2024-12-28 11:35:00 +09:00
Nobuyoshi Nakada
fb18bb183c
[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-28 11:25:57 +09:00
Takashi Kokubun
667a0f9f92
Revert "[Bug #20965 ] Define it
like an ordinary argument" ( #12418 )
...
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.
2024-12-23 04:46:50 +00:00
Nobuyoshi Nakada
7b2ae8df90
[Bug #20969 ] Pass assignable
from ripper
...
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.
2024-12-19 23:20:09 +09:00
Nobuyoshi Nakada
46fec0f62a
[Bug #20965 ] Define it
like an ordinary argument ( #12398 )
...
Also fixes [Bug #20955 ]
2024-12-18 23:12:16 -08:00
ydah
ce2f398386
Remove unused macros from parse.y
2024-12-10 12:21:19 +09:00
ydah
bfb7571d24
Remove minimum Bison version requirement from parse.y
...
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-12-10 11:50:36 +09:00
S.H.
d278d352f9
Introduce inline_primary rule
...
Introduce inline_primary rule to merge the same BNF pattern
2024-10-25 22:26:29 +09:00
ydah
1c762d9566
[Bug #20789 ] Fix an invalid syntax error when ->a=1...{}
...
https://bugs.ruby-lang.org/issues/20789
2024-10-09 23:58:19 +09:00
Nobuyoshi Nakada
f37e6d7f7b
Merge rb_parser_enc_compatible_latter
into rb_parser_enc_compatible
2024-10-05 16:07:57 +09:00
Nobuyoshi Nakada
9dbbd0181f
Parser string encoding is always ASCII-compatible
2024-10-05 15:59:44 +09:00
tompng
6743e6285a
[Bug #20784 ] Fix incomplete character syntax followed by EOF
2024-10-05 15:59:01 +09:00
ydah
169a5ee99e
Use user defined inline rules user_or_keyword_variable
2024-10-01 23:59:58 +09:00
Nobuyoshi Nakada
86ae409467
[Bug #20764 ] Refactor argument forwarding in lambda
...
Reject argument forwarding in lambda:
- without parentheses
- after optional argument(s)
2024-10-01 20:00:22 +09:00
ydah
ac2786757e
Use Named Reference
2024-09-30 18:04:41 +09:00
ydah
044e57ed7c
Implement SPLAT NODE keyword locations
2024-09-30 18:04:41 +09:00
tompng
b9e225fcbf
Allow dot3 in defs singleton
2024-09-28 22:37:44 +09:00
ydah
8f678d6989
Implement OP_ASGN2 NODE locations
2024-09-28 20:53:09 +09:00
Nobuyoshi Nakada
7e19904c88
Remove on RSTRING_END
dependency from parser
2024-09-28 01:59:33 +09:00
Nobuyoshi Nakada
94ad2c3fe9
Reduce creating rb_parser_string_t
repeatedly for literals.
...
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.
2024-09-27 23:10:14 +09:00
Nobuyoshi Nakada
710d916c32
Add wrapper macros of rb_parser_str_buf_cat
2024-09-27 23:10:14 +09:00
S-H-GAMELINKS
7f83bd3732
Reduce is_ascii_string
function dependency for parser
...
Changed to use `rb_parser_is_ascii_string` function instead of `is_ascii_string` function
2024-09-27 19:34:35 +09:00
ydah
eff16d9302
Implement OP_ASGN1 NODE locations
2024-09-27 18:20:00 +09:00
Nobuyoshi Nakada
80e483afac
Fold rules [ci skip]
2024-09-26 06:05:35 +09:00
Peter Zhu
407f8b8716
Fix memory leak in Ripper for indented heredocs
...
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
2024-09-25 08:56:14 -04:00
ydah
509b577e01
Implement BLOCK_PASS NODE keyword locations
2024-09-25 09:15:43 +09:00
ydah
31a88d1554
Implement RETURN NODE keyword locations
2024-09-25 09:06:42 +09:00
ydah
b811a9a097
Implement CASE3 NODE keyword locations
2024-09-23 09:19:37 +09:00
ydah
5334766beb
Implement CASE2 NODE keyword locations
2024-09-23 09:19:37 +09:00
ydah
feac2b4b77
Implement CASE NODE keyword locations
2024-09-23 09:19:37 +09:00
S-H-GAMELINKS
95d26ee41e
Reuse dedent_string function in rb_ruby_ripper_dedent_string function
...
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.
2024-09-22 12:22:20 +09:00
Jeremy Evans
268c72377b
Raise a compile error for break/next/redo inside eval in cases where it is 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>
2024-09-18 16:54:56 -07:00
Luke Gruber
5d358b660d
Fix issue with super and forwarding arguments in prism_compile.c
...
Fixes [Bug #20720 ]
2024-09-11 16:41:46 -04:00
ydah
d03e0d1c35
Implement BREAK, NEXT and REDO NODE locations
2024-09-11 18:01:16 +09:00
ydah
4e6091ce09
Implement WHILE and UNTIL NODE locations
2024-09-11 09:28:55 +09:00
ydah
d52e599538
Implement WHEN NODE locations
2024-09-09 10:34:02 +09:00
ydah
32680f543c
Implement AND/OR NODE operator locations
2024-09-05 13:03:28 +09:00
ydah
ab18b1b4f5
Implement VALIAS NODE keyword locations
2024-09-04 14:36:35 +09:00
ydah
a2243ee48b
Implement ALIAS NODE keyword locations
2024-09-03 22:09:08 +09:00
ydah
af143d8a74
Implement UNDEF NODE keyword locations
2024-09-03 21:15:12 +09:00
yui-knk
c93d07ed74
[Bug #20695 ] Do not create needless string object in parser
...
`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
```
2024-09-03 08:40:07 +09:00