57 Commits

Author SHA1 Message Date
S-H-GAMELINKS
23c4ac9559 Remove rb_enc_associate for Parser 2025-02-15 15:37:09 +09:00
S-H-GAMELINKS
ace39a3ed4 Remove rb_exc_raise for Parser 2025-02-02 16:58:15 +09:00
S-H-GAMELINKS
baf22a0578 Remove rb_usascii_encoding for Parser 2025-01-28 18:22:35 +09:00
S-H-GAMELINKS
5c95898e93 Remove rb_obj_as_string for Parser
Ruby Parser not used rb_obj_as_string.
And obj_as_string property can be removed from Universal Parser.
2025-01-20 23:52:56 +09:00
S-H-GAMELINKS
975461bf88 Remove SYM2ID for Parser
Ruby Parser not used SYM2ID.
And sym2id property can be removed from Universal Parser.
2025-01-06 20:17:47 +09:00
S-H-GAMELINKS
ba82399558 Remove rb_ary_push for parser 2025-01-02 17:11:45 +09:00
Nobuyoshi Nakada
bce1bd1dc1
rb_strlen_lit: support wide string literals 2024-11-10 22:52:17 +09:00
S-H-GAMELINKS
5c1e43277e Remove rb_ary_new for parser
rb_ary_new function was not used by the parser and could be removed.
2024-10-25 22:32:38 +09:00
Nobuyoshi Nakada
7e19904c88 Remove on RSTRING_END dependency from parser 2024-09-28 01:59:33 +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
S-H-GAMELINKS
3e742579bb Remove rb_str_cat for parser 2024-09-26 19:20:57 +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
S-H-GAMELINKS
0cc5f77c07 Remove unused functions from struct rb_parser_config_struct
StringValueCStr has not used in parse.y
2024-06-02 09:50:43 +09:00
Yusuke Endoh
a15e4d405b Revert 528c4501f46fbe1e06028d673a777ef124d29829
Recently, `TestRubyLiteral#test_float` fails randomly.

```
  1) Error:
TestRubyLiteral#test_float:
ArgumentError: SyntaxError#path changed: "(eval at /home/chkbuild/chkbuild/tmp/build/20240527T050036Z/ruby/test/ruby/test_literal.rb:642)"->"(eval at /home/chkbuild/chkbuild/tmp/build/20240527T050036Z/ruby/test/ruby/test_literal.rb:642)"
```
https://rubyci.s3.amazonaws.com/s390x/ruby-master/log/20240527T050036Z.fail.html.gz

According to Launchable, the first failure was on Apr 30.
This is just when 528c4501f46fbe1e06028d673a777ef124d29829 was
committed. I don't know if the change is really the cause, but I want to
revert it once to see if the random failure disappears.
2024-05-31 18:24:43 +09:00
Nobuyoshi Nakada
3c16d93cd3 Constify encoding type in universal parser
Fixed warning about discarding modifiers.

```
../src/ruby_parser.c:677:48: warning: passing 'rb_encoding *' (aka 'const struct OnigEncodingTypeST *') to parameter of type 'void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
  677 |     ast = rb_parser_compile(p, gets, ptr, len, enc, input, line);
      |                                                ^~~
../src/internal/parse.h:58:128: note: passing argument to parameter 'fname_enc' here
   58 | rb_ast_t *rb_parser_compile(rb_parser_t *p, rb_parser_lex_gets_func *gets, const char *fname_ptr, long fname_len, rb_encoding *fname_enc, rb_parser_input_data input, int line);
      |                                                                                                                                ^
```
2024-05-13 08:26:54 +09:00
yui-knk
528c4501f4 Use rb_parser_string_t * as ruby_sourcefile_string
This reduces dependency on VALUE.
2024-04-30 09:00:05 +09:00
yui-knk
813e12557a Remove unused functions from struct rb_parser_config_struct 2024-04-24 07:59:51 +09:00
yui-knk
e61f76ce9e Remove unused functions from struct rb_parser_config_struct 2024-04-23 13:11:46 +09:00
yui-knk
3aa046803d Remove unused functions from struct rb_parser_config_struct 2024-04-23 11:18:52 +09:00
yui-knk
c7d9376cb5 Remove unused functions from struct rb_parser_config_struct 2024-04-23 07:20:22 +09:00
S-H-GAMELINKS
381ce130ae Remove unused functions from struct rb_parser_config_struct 2024-04-21 09:55:17 +09:00
yui-knk
cee985ea83 Remove unused functions from struct rb_parser_config_struct 2024-04-20 18:08:33 +09:00
yui-knk
ebaa87f626 Remove unused functions from struct rb_parser_config_struct 2024-04-16 07:15:45 +09:00
yui-knk
924b928e35 Remove unused functions from struct rb_parser_config_struct 2024-04-14 09:08:19 +09:00
yui-knk
501a32c630 Remove duplicated st_init_table_with_size definition
`st_init_table_with_size` is already defined in universal_parser.c.
2024-04-11 12:57:25 +09:00
yui-knk
87ad5ca3ca Remove unused function from struct rb_parser_config_struct 2024-04-11 11:56:28 +09:00
yui-knk
4dbd9c7fec Remove unused function from struct rb_parser_config_struct 2024-04-09 09:58:05 +09:00
yui-knk
0b4db711dd Remove unused function from struct rb_parser_config_struct 2024-04-06 22:03:26 +09:00
S-H-GAMELINKS
dae503874d Remove unused functions from struct rb_parser_config_struct 2024-04-06 09:29:44 +09:00
yui-knk
bd728a625a Remove unused functions from struct rb_parser_config_struct 2024-04-05 10:04:48 +09:00
yui-knk
cfd48adb2f Remove unused function from struct rb_parser_config_struct 2024-04-04 19:13:03 +09:00
yui-knk
e816ab0b0c Remove rb_imemo_tmpbuf_t from parser
No parser semantic value types are `VALUE` then no need to
use imemo for managing semantic value stack anymore.
2024-04-02 19:37:27 +09:00
yui-knk
799e854897 [Feature #20331] Simplify parser warnings for hash keys duplication and when clause duplication
This commit simplifies warnings for hash keys duplication and when clause duplication,
based on the discussion of https://bugs.ruby-lang.org/issues/20331.
Warnings are reported only when strings are same to ohters.
2024-04-02 08:26:58 +09:00
S-H-GAMELINKS
0774232bf3 Remove unnecessary macros and functions for Universal Parser 2024-04-01 12:05:16 +09:00
HASUMI Hitoshi
9a19cfd4cd [Universal Parser] Reduce dependence on RArray in parse.y
- Introduce `rb_parser_ary_t` structure to partly eliminate RArray from parse.y
  - In this patch, `parser_params->tokens` and `parser_params->ast->node_buffer->tokens` are now `rb_parser_ary_t *`
  - Instead, `ast_node_all_tokens()` internally creates a Ruby Array object from the `rb_parser_ary_t`
  - Also, delete `rb_ast_tokens()` and `rb_ast_set_tokens()` in node.c

- Implement `rb_parser_str_escape()`
  - This is a port of the `rb_str_escape()` function in string.c
  - `rb_parser_str_escape()` does not depend on `VALUE` (RString)
  - Instead, it uses `rb_parser_stirng_t *`
  - This function works when --dump=y option passed

- Because WIP of the universal parser, similar functions like `rb_parser_tokens_free()` exist in both node.c and parse.y. Refactoring them may be needed in some way in the future

- Although we considered redesigning the structure: `ast->node_buffer->tokens` into `ast->tokens`, we leave it as it is because `rb_ast_t` is an imemo. (We will address it in the future)
2024-03-12 17:17:52 +09:00
Peter Zhu
01f9b2ae41 Use rb_str_to_interned_str in parse.y
This commit changes rb_fstring to rb_str_to_interned_str in parse.y.
rb_fstring is private so it shouldn't be used by ripper.
2024-02-23 13:33:46 -05:00
yui-knk
91cb303531 Remove not used universal parser macros and functions 2024-02-21 13:36:45 +09:00
S-H-GAMELINKS
fba647087b Remove uneeded Universal Parser properties 2024-02-20 19:02:24 +09:00
Nobuyoshi Nakada
b1d70e4264
[Bug #20280] Check by rb_parser_enc_str_coderange
Co-authored-by: Yuichiro Kaneko <spiketeika@gmail.com>
2024-02-19 16:33:26 +09:00
Nobuyoshi Nakada
fcc55dc226
[Bug #20280] Raise SyntaxError on invalid encoding symbol 2024-02-19 16:33:26 +09:00
Peter Zhu
a71d1ed838 Fix memory leak when parsing invalid hash symbol
For example:

    10.times do
      100_000.times do
        eval('{"\xC3": 1}')
      rescue EncodingError
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    32032
    48464
    66112
    84192
    100592
    117520
    134096
    150656
    167168
    183760

After:

    17120
    17120
    17120
    17120
    18560
    18560
    18560
    18560
    18560
    18560
2024-02-13 11:05:56 -05:00
yui-knk
33c1e082d0 Remove ruby object from string nodes
String nodes holds ruby string object on `VALUE nd_lit`.
This commit changes it to `struct rb_parser_string *string`
to reduce dependency on ruby object.
Sometimes these strings are concatenated with other string
therefore string concatenate functions are needed.
2024-02-09 14:20:17 +09:00
S.H
f3df218f48
Introduced rb_node_const_decl_val function
Introduce `rb_node_const_decl_val` function to allow `rb_ary_join` and
`rb_ary_reverse` functions to be removed from Universal Parser.
2024-01-31 13:31:38 +09:00
yui-knk
52d9e55903 Statically allocate parser config 2024-01-12 21:17:41 +09:00
S-H-GAMELINKS
ad7aee35e4 Remove unneeded rb_parser_config_struct struct properties for Universal Parser 2024-01-07 21:16:31 +09:00
S-H-GAMELINKS
1b8d01136c Introduce Numeric Node's 2024-01-07 09:24:34 +09:00
yui-knk
4374236e95 Add errno_ptr property for Universal Parser 2023-12-28 13:17:36 +09:00
yui-knk
73fa322497 Add ary_modify property for Universal Parser 2023-12-28 09:00:44 +09:00
Nobuyoshi Nakada
a075c55d0c Manage rb_strterm_t without imemo 2023-10-14 11:08:43 +09:00
yui-knk
fb7a2ddb4b Directly free structure managed by imemo tmpbuf
NODE_ARGS, NODE_ARYPTN, NODE_FNDPTN manage memory of their
structure by imemo tmpbuf Object.
However rb_ast_struct has reference to NODE. Then these
memory can be freed directly when rb_ast_struct is freed.

This commit reduces parser's dependency on CRuby functions.
2023-09-22 11:25:53 +09:00