Граф коммитов

2569 Коммитов

Автор SHA1 Сообщение Дата
yui-knk 776dbbba72 Remove hack for ripper.y generation
Before Rearchitect Ripper (89cfc15), parser and ripper used different
semantic value data type for same symbols.
"ext/ripper/tools/preproc.rb" replaced these types when it generated
ripper.y. Starting the line with other than `%token` suppressed
the type replacement.
However, after Rearchitect Ripper, both parser and ripper use
same semantic value data type. Therefore these comments are not needed
anymore.
2024-02-21 09:16:09 +09:00
yui-knk e7ab5d891c Introduce NODE_REGX to manage regexp literal 2024-02-21 08:06:48 +09:00
yui-knk 7cb8fd7800 Move ripper_validate_object to ripper_init.c.tmpl 2024-02-20 19:19:31 +09:00
yui-knk 474f41880f Suppress unused function warning for UNIVERSAL_PARSER build
Suppress the warning:

```
parse.y:2221:1: warning: unused function 'rb_parser_str_hash' [-Wunused-function]
 2221 | rb_parser_str_hash(rb_parser_string_t *str)
      | ^~~~~~~~~~~~~~~~~~
```
2024-02-20 19:07:40 +09:00
yui-knk 2a4b6ed37c Workaround for `Prism::ParseTest#test_filepath` for "unparser/corpus/literal/def.txt"
See the discussion on https://github.com/ruby/ruby/pull/9923
2024-02-20 17:33:58 +09:00
yui-knk 89cfc15207 [Feature #20257] Rearchitect Ripper
Introduce another semantic value stack for Ripper so that
Ripper can manage both Node and Ruby Object separately.
This rearchitectutre of Ripper solves these issues.
Therefore adding test cases for them.

* [Bug 10436] https://bugs.ruby-lang.org/issues/10436
* [Bug 18988] https://bugs.ruby-lang.org/issues/18988
* [Bug 20055] https://bugs.ruby-lang.org/issues/20055

Checked the differences of `Ripper.sexp` for files under `/test/ruby`
are only on test_pattern_matching.rb.
The differences comes from the differences between
`new_hash_pattern_tail` functions between parser and Ripper.
Ripper `new_hash_pattern_tail` didn’t call `assignable` then
`kw_rest_arg` wasn’t marked as local variable.
This is also fixed by this commit.

```
--- a/./tmp/before/test_pattern_matching.rb
+++ b/./tmp/after/test_pattern_matching.rb
@@ -3607,7 +3607,7 @@
                  [:in,
                   [:hshptn, nil, [], [:var_field, [:@ident, “a”, [984, 13]]]],
                   [[:binary,
-                    [:vcall, [:@ident, “a”, [985, 10]]],
+                    [:var_ref, [:@ident, “a”, [985, 10]]],
                     :==,
                     [:hash, nil]]],
                   nil]]],
@@ -3662,7 +3662,7 @@
                  [:in,
                   [:hshptn, nil, [], [:var_field, [:@ident, “a”, [993, 13]]]],
                   [[:binary,
-                    [:vcall, [:@ident, “a”, [994, 10]]],
+                    [:var_ref, [:@ident, “a”, [994, 10]]],
                     :==,
                     [:hash,
                      [:assoclist_from_args,
@@ -3813,7 +3813,7 @@
                    [:command,
                     [:@ident, “raise”, [1022, 10]],
                     [:args_add_block,
-                     [[:vcall, [:@ident, “b”, [1022, 16]]]],
+                     [[:var_ref, [:@ident, “b”, [1022, 16]]]],
                      false]]],
                   [:else, [[:var_ref, [:@kw, “true”, [1024, 10]]]]]]]],
                nil,
@@ -3876,7 +3876,7 @@
                      [:@int, “0”, [1033, 15]]],
                     :“&&“,
                     [:binary,
-                     [:vcall, [:@ident, “b”, [1033, 20]]],
+                     [:var_ref, [:@ident, “b”, [1033, 20]]],
                      :==,
                      [:hash, nil]]]],
                   nil]]],
@@ -3946,7 +3946,7 @@
                      [:@int, “0”, [1042, 15]]],
                     :“&&“,
                     [:binary,
-                     [:vcall, [:@ident, “b”, [1042, 20]]],
+                     [:var_ref, [:@ident, “b”, [1042, 20]]],
                      :==,
                      [:hash,
                       [:assoclist_from_args,
@@ -5206,7 +5206,7 @@
                      [[:assoc_new,
                        [:@label, “c:“, [1352, 22]],
                        [:@int, “0”, [1352, 25]]]]]],
-                   [:vcall, [:@ident, “r”, [1352, 29]]]],
+                   [:var_ref, [:@ident, “r”, [1352, 29]]]],
                   false]]],
                [:binary,
                 [:call,
@@ -5299,7 +5299,7 @@
                       [:assoc_new,
                        [:@label, “c:“, [1367, 34]],
                        [:@int, “0”, [1367, 37]]]]]],
-                   [:vcall, [:@ident, “r”, [1367, 41]]]],
+                   [:var_ref, [:@ident, “r”, [1367, 41]]]],
                   false]]],
                [:binary,
                 [:call,
@@ -5931,7 +5931,7 @@
              [:in,
               [:hshptn, nil, [], [:var_field, [:@ident, “r”, [1533, 11]]]],
               [[:binary,
-                [:vcall, [:@ident, “r”, [1534, 8]]],
+                [:var_ref, [:@ident, “r”, [1534, 8]]],
                 :==,
                 [:hash,
                  [:assoclist_from_args,
```
2024-02-20 17:33:58 +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
Yusuke Endoh 25d74b9527 Do not include a backtick in error messages and backtraces
[Feature #16495]
2024-02-15 18:42:31 +09:00
Nobuyoshi Nakada c57880e68d
Show the invalid source encoding in messages 2024-02-15 13:39:33 +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 038189b61f Use dedicated parser_string hash function
Define and use `rb_parser_str_hash` for `rb_parser_string_t`
instead of `rb_str_hash` to remove dependency on `rb_str_hash`.
2024-02-13 10:56:32 +09:00
yui-knk 8a345860d3 Warn duplication of `__ENCODING__` on the hash
```
$ ruby -e 'h = { __ENCODING__ => 1, __ENCODING__ => 2 }'
-e:1: warning: key #<Encoding:UTF-8> is duplicated and overwritten on line 1
```
2024-02-13 08:40:14 +09:00
yui-knk 7fc89a9262 Use Node for `warn_duplicate_keys` st_table keys 2024-02-12 17:46:22 +09:00
yui-knk fdd92c2d61 Fix the variable to be checked
It should check the result of `rb_parser_search_nonascii`.
2024-02-10 18:58:42 +09: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
Peter Zhu b2392c6be4 Fix memory leak when parsing invalid pattern matching
If the pattern matching is invalid, then the pvtbl would get leaked. For
example:

    10.times do
      100_000.times do
        eval(<<~RUBY)
          case {a: 1}
          in {"a" => 1}
          end
        RUBY
      rescue SyntaxError
      end

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

Before:

    28096
    44768
    61472
    78512
    94992
    111504
    128096
    144528
    161008
    177472

After:

    14096
    14112
    14112
    14176
    14208
    14240
    14240
    14240
    14240
    14240
2024-02-07 12:15:33 -05:00
yui-knk 68b57ceb46 Use bool to check ascii only in parse_ident
No need to use ENC_CODERANGE to record ascii only or not.
2024-02-03 09:15:41 +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
Nobuyoshi Nakada 23b8337cd1
[Bug #20219] `gettable` returns NULL on error 2024-01-28 19:15:31 +09:00
Nobuyoshi Nakada 5f733a1ae7
[Bug #20217] `rescue` block is void only if all children are void 2024-01-28 18:44:09 +09:00
Nobuyoshi Nakada fed877c791
[Bug #20217] `return` with `ensure` is a void value expression 2024-01-28 18:44:09 +09:00
Nobuyoshi Nakada e018036d89
Rename `nd_head` in `RNode_RESBODY` as `nd_next` 2024-01-28 11:12:22 +09:00
Nobuyoshi Nakada 0f98d284f3
Remove unused `nd_resq` from `RNode_ENSURE` 2024-01-28 11:11:13 +09:00
S.H 9b40f42c22
Introduce `NODE_ENCODING`
`__ENCODING__ `was managed by `NODE_LIT` with Encoding object. 

Introduce `NODE_ENCODING` for
1. `__ENCODING__` is detectable from AST Node.
2. Reduce dependency Ruby object for parse.y
2024-01-27 08:11:10 +00:00
yui-knk 68b9a32a62 bvar is not NODE but ID
Before this commit `ruby -y -e 'tap {|;x, y|}'` failed with SEGV.
This change fixes it.
2024-01-27 16:50:35 +09:00
Nobuyoshi Nakada ff55d6b8e1
Use `token_seen` and simplify `comment_at_top`
Instead of scanning before the current comment.
2024-01-25 15:06:14 +09:00
Jeremy Evans 4f77d8d328 Do not use ruby2_keywords for ... argument forwarding
This allows ... argument forwarding to benefit from Allocationless
Anonymous Splat Forwarding, allowing the `f` call below to not
allocate an array or a hash.

```ruby
a = [1]
kw = {b: 2}

def c(a, b:)
end

def f(...)
  c(...)
end

f(*a, **kw)
```

This temporarily skips prism locals tests until prism is changed
to use * and ** for ..., instead of using ruby2_keywords.

Ignore failures in rbs bundled gems tests, since they fail due
to this change.
2024-01-24 18:25:55 -08:00
yui-knk ee7f63ebba Make lastline and nextline to be rb_parser_string
This commit changes `struct parser_params` lastline and nextline
from `VALUE` (String object) to `rb_parser_string_t *` so that
dependency on Ruby Object is reduced.
`parser_string_buffer_t string_buffer` is added to `struct parser_params`
to manage `rb_parser_string_t` pointers of each line. All allocated line
strings are freed in `rb_ruby_parser_free`.
2024-01-23 08:58:16 +09:00
yui-knk 3d19409637 Use index for referring to symbols in `args` rule instead of named references
In `args: args ',' arg_splat`, `args` is not unique name.
Currently the associated rule is interpreted as
`$$ = rest_arg_append(p, $$, $3, &@$);`.
The action works as expected because `$$` is initialized with
`$1` before each action is executed.
However it's misleading then change to use index.
2024-01-22 16:05:43 +09:00
Nobuyoshi Nakada 0610f555ea
Constify `rb_global_parser_config` 2024-01-14 17:55:11 +09:00
yui-knk ccd45a1399 Stop using Array to manage dummy `end` token locations
Before this commit, Array is used to store token locations
which expect `end` token, e.g. `class` and `module`.
This commit introduces dedicated struct to manage them
so that dependency on Ruby Object is reduced.
2024-01-13 20:41:22 +09:00
S-H-GAMELINKS 524770d3dc Suppress warnings in parser_set_encode function 2024-01-12 22:46:07 +09:00
yui-knk b35e21b388 Remove reference counter from rb_parser_config
It's allocated outside of parser then no need to track
reference count in rb_parser_config.
2024-01-12 21:17:41 +09:00
yui-knk 52d9e55903 Statically allocate parser config 2024-01-12 21:17:41 +09:00
yui-knk c3b2436154 `set_yylval_literal` is not used 2024-01-12 21:11:00 +09:00
Nobuyoshi Nakada 3d3bc029c5
Reject encodings determined at runtime as source code encodings
The encodings determined at runtime are affected by the runtime
environment, such as the OS and locale, while the file contents are
not.
2024-01-11 18:46:51 +09:00
Nobuyoshi Nakada 7cc8d58cc9
Remove duplicate function `nd_st_key_val` 2024-01-11 17:46:09 +09:00
S-H-GAMELINKS a971229462 Fixed return values for some node types in nd_st_key function 2024-01-11 12:26:30 +09:00
Nobuyoshi Nakada e59a730477
`st_index_t` is not `VALUE` 2024-01-10 14:06:33 +09:00
Peter Zhu 02d8bad6e1 Fix memory leak in parser for invalid syntax
The strterm is leaked when there is invalid syntax.

For example:

    10.times do
      100_000.times do
        begin
          RubyVM::InstructionSequence.compile('private def foo = puts "Hello"')
        rescue SyntaxError
        end
      end

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

Before:

    20384
    26256
    32592
    36720
    42016
    47888
    53248
    57456
    62928
    65936

After:

    16720
    17488
    17616
    17616
    17616
    17616
    17616
    17616
    17616
    16032

Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
2024-01-09 09:41:02 -05:00
Nobuyoshi Nakada 38bc107f0b
Convert a series of `else if` lines to a `switch` 2024-01-09 18:47:15 +09:00
yui-knk db476cc71c Introduce NODE_SYM to manage symbol literal
`:sym` was managed by `NODE_LIT` with `Symbol` object.
This commit introduces `NODE_SYM` so that

1. Symbol literal is detectable from AST Node
2. Reduce dependency on ruby object
2024-01-09 16:07:19 +09:00
Nobuyoshi Nakada 4b01983bf8
Simplify empty hahs with DSTAR 2024-01-09 13:05:34 +09:00
Nobuyoshi Nakada a4406bc89a
Extract repeating NODE references as a local variable 2024-01-09 13:04:26 +09:00
yui-knk 5ecf2d2880 Use `strcmp` to compare strings 2024-01-09 07:42:44 +09:00
yui-knk 41e2d180a3 Do not convert NODE_STR to NODE_LIT when the string is hash key
parse.y converted NODE_STR when the string is hash key like

```
h1 = {"str1" => 1}
m1("str2" => 2)
m2({"str3" => 3})
```

This commit stop the conversion.
`static_literal_node_p` needs to know the node is for hash key or not
for the optimization.
2024-01-08 18:48:24 +09:00
yui-knk 7ffff3e043 Change numeric node value functions argument to `NODE *`
Change the argument to align with other node value functions
like `rb_node_line_lineno_val`.
2024-01-08 14:02:48 +09:00
yui-knk 9527093759 Fix numeric node print by `-y` option
These nodes are not NOTE_LIT, so need to treat separately.
2024-01-08 11:57:30 +09:00
Nobuyoshi Nakada 8b86d6f0c1
Suppress unused-but-set-variable warning in ripper
`set_yylval_node` in ripper does not use the argument at all.
2024-01-08 01:23:58 +09:00
Nobuyoshi Nakada c30b8ae947
Adjust styles and indents [ci skip] 2024-01-08 00:50: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
yui-knk 83c98ead4e Do not remove hash duplicated keys in parse.y
When hash keys are duplicated, e.g. `h = {k: 1, l: 2, k: 3}`,
parser changes node structure for correct compilation.
This generates tricky AST. This commit removes AST manipulation
from parser to keep AST structure simple.
2024-01-07 16:18:16 +09:00
yui-knk 9d3dcb86d1 Check hash key duplication for `__LINE__` and `__FILE__` 2024-01-07 14:32:10 +09:00
S-H-GAMELINKS 1b8d01136c Introduce Numeric Node's 2024-01-07 09:24:34 +09:00
yui-knk 7a050638b1 Introduce NODE_FILE
`__FILE__` was managed by `NODE_STR` with `String` object.
This commit introduces `NODE_FILE` and `struct rb_parser_string` so that

1. `__FILE__` is detectable from AST Node
2. Reduce dependency ruby object
2024-01-02 14:19:42 +09:00
yui-knk 6ec4d203f7 Warn "literal in condition" for `__LINE__`
Print warning for a code like

```ruby
if __LINE__
end

# => warning: literal in condition
```
2024-01-02 09:50:32 +09:00
yui-knk 1ade170a6c Introduce NODE_LINE
`__LINE__` was managed by `NODE_LIT` with `Integer` object.
This commit introduces `NODE_LINE` so that

1. `__LINE__` is detectable from AST Node
2. Reduce dependency ruby object
2023-12-29 18:32:27 +09:00
Nobuyoshi Nakada bc002971b6
[Bug #20094] Distinguish `begin` and parentheses 2023-12-27 17:50:15 +09:00
Nobuyoshi Nakada 15c280639e
Initialize rb_node_block_t::nd_end at creation 2023-12-27 17:50:15 +09:00
Nobuyoshi Nakada d0546012f2
Use NODE_ERROR as placeholder of error instead of NODE_BEGIN 2023-12-27 17:50:15 +09:00
yui-knk 33345d2e9f Include new node types into %printer 2023-12-27 12:25:17 +09:00
Nobuyoshi Nakada 596db9c1f4 [Feature #19370] Blocks without anonymous parameters should not affect 2023-12-25 18:28:21 +09:00
Takashi Kokubun 44592c4e20
Implement `it` (#9199)
[[Feature #18980]](https://bugs.ruby-lang.org/issues/18980)

Co-authored-by: Yusuke Endoh <mame@ruby-lang.org>
2023-12-25 01:15:41 -08:00
Nobuyoshi Nakada a9f0961831 [Feature #19370] Prohibit nesting anonymous parameter forwarding 2023-12-25 14:44:04 +09:00
Nobuyoshi Nakada 40e3f782dd Extract `forwarding_arg_check` function 2023-12-22 23:08:10 +09:00
Nobuyoshi Nakada 11c2aa035b Extract `arg_splat` nonterminal symbol 2023-12-22 23:08:10 +09:00
Nobuyoshi Nakada 92b10f5be7 [Bug #20062] Fixed numbered parameter syntax error
At the method definition, the local scope that saves the context of
the numbered parameters needs to be pushed before saving.
2023-12-16 02:11:51 +09:00
Nobuyoshi Nakada 9b7a964318 [Bug #19877] Flip-flop needs to be direct condition 2023-12-08 12:53:47 +09:00
Takashi Kokubun c6eb355e04 Revert "Warn `it` only with -W:deprecated"
This reverts commit 5458252bb0.

Revert "Fallback rb_warn_deprecated for UNIVERSAL_PARSER"

This reverts commit 680be886f4.

matz actually preferred always warning `it`.
2023-12-07 00:03:03 -08:00
Takashi Kokubun 680be886f4 Fallback rb_warn_deprecated for UNIVERSAL_PARSER 2023-12-07 00:00:36 -08:00
Takashi Kokubun 5458252bb0 Warn `it` only with -W:deprecated 2023-12-06 23:44:02 -08:00
Takashi Kokubun ae76c8a11e
Warn `it` (#9152)
https://bugs.ruby-lang.org/issues/18980
2023-12-07 07:14:59 +00:00
Nobuyoshi Nakada a607d62d8c [Bug #20033] Dynamic regexp should not assign captures 2023-12-02 03:57:41 +09:00
Nobuyoshi Nakada e5e1f9813e [Bug #19838] Flush delayed token nonconsecutive with the next token 2023-12-02 02:41:39 +09:00
Nobuyoshi Nakada add0ab07e8 Extract `end_with_newline_p` 2023-12-02 02:41:39 +09:00
Nobuyoshi Nakada 6e2b10d456 Prefer proper enum over bare int 2023-12-02 02:41:39 +09:00
Nobuyoshi Nakada e36b9760fd
Dispatch invalid hex escape content too 2023-12-01 15:04:30 +09:00
Nobuyoshi Nakada d503e1b95a
[Bug #20030] dispatch invalid escaped character without ignoring it 2023-12-01 15:04:30 +09:00
Nobuyoshi Nakada 1802d14ca8 [Bug #19877] Assign captures for direct regexp literal only 2023-11-30 21:40:22 +09:00
TSUYUSATO Kitsune fe746747b4 Reject 'class << (return); end` by "void value expression" 2023-11-21 14:07:47 +09:00
yui-knk 51149f335e Keep unused literal nodes
For static analysis, it’s better to keep unused literal nodes.
If simply change `block_append` to fall through, both "unused literal ignored"
and "possibly useless use of a literal in void context" warnings
are shown for the same line. But it’s verbose then remove
"unused literal ignored" warning.

This kind of optimization is already implemented on compile.c.
`compile_block` calls `iseq_compile_each0` with `popped = 1` when NODE_BLOCK
has next.
2023-10-31 17:49:12 +09:00
Nobuyoshi Nakada 13c9cbe09e
Embed `rb_args_info` in `rb_node_args_t` 2023-10-30 00:19:43 +09:00
Nobuyoshi Nakada c8d162c889
[Bug #19973] Warn duplicated keyword arguments after keyword splat 2023-10-26 14:28:39 +09:00
Nobuyoshi Nakada 2f8a719b6a Removed unused argument
Eventually, `read_escape` does not use `encp`.
2023-10-25 21:40:41 +09:00
Nobuyoshi Nakada 839b763119 Use named reference for dyna_push 2023-10-23 17:40:33 +09:00
Nobuyoshi Nakada 7e80f0b5a2 Extract p_in_kwarg to save and update lexer contexts 2023-10-23 17:40:33 +09:00
Nobuyoshi Nakada 428f9f5dc0 Move push_pvtbl and push_pktbl in nterms 2023-10-23 17:40:33 +09:00
Nobuyoshi Nakada 3b05238289 Extract p_assoc and p_in to save lexer contexts 2023-10-23 17:40:33 +09:00
yui-knk 08e25985d1 Expand OP_ASGN1 nd_args to nd_index and nd_rvalue
ARGSCAT has been used for nd_args to hold index and rvalue,
because there was limitation on the number of members for Node.
We can easily change structure of node now, let's expand it.
2023-10-20 07:56:20 +09:00
yui-knk 606452d1a9 Remove not used fields from STR 2023-10-15 16:16:06 +09:00
yui-knk 5342dbf00b Check node type before accessing nd_next
This is also a preparation for removing not_used members from
STR NODE. Current codes work without node type check because NODE_STR
has not_used2 member corresponding to nd_next of NODE_LIST and
NODE_DSTR. However it causes problme once not_used members are
removed from NODE_STR.
2023-10-15 16:16:06 +09:00
yui-knk e7e31d7784 Stop updating node type from NODE_STR to NODE_DSTR
This is a preparation for removing not_used members from STR NODE.
Once not_used members are removed from STR NODE, STR NODE is smaller than
DSTR NODE. Therefore allocate NODE_DSTR instead of reusing NODE_STR.
2023-10-15 16:16:06 +09:00
yui-knk a4e3d595cd Remove not used fields from XSTR 2023-10-15 16:16:06 +09:00
yui-knk cab67d227a Remove not used fields from LIT 2023-10-15 16:16:06 +09:00
yui-knk 25072d2e87 Fix node type casts
Use new node type set by nd_set_type.
2023-10-14 11:12:20 +09:00
Nobuyoshi Nakada a405b28e85 Delete heredoc line mark references 2023-10-14 11:08:43 +09:00
Nobuyoshi Nakada 5fc9810bf3 Shorten `rb_strterm_literal_t` members 2023-10-14 11:08:43 +09:00
Nobuyoshi Nakada a075c55d0c Manage `rb_strterm_t` without imemo 2023-10-14 11:08:43 +09:00
Nobuyoshi Nakada cb06b6632a Remove unions in `rb_strterm` structs for alignment 2023-10-14 11:08:43 +09:00
yui-knk 2794a8fef6 [Bug #19919] Warn class variable assignment and constant declaration in condition 2023-10-13 07:35:24 +09:00
Nobuyoshi Nakada 81399a5c46
Use `lex_eol` macros 2023-10-13 02:32:45 +09:00
Nobuyoshi Nakada 17b0643392
[Bug #19924] Source code should be unsigned char stream
Use `peekc` or `nextc` to fetch the next character, instead of reading
from `lex.pcur` directly, for compilers that plain char is signed.
2023-10-13 02:28:35 +09:00
yui-knk f9fe7aeef4 Extract NODE_FL_NEWLINE access to macro 2023-10-11 19:22:34 +09:00
Nobuyoshi Nakada a84d0945fa
Semicolon after `SWITCH_BY_COND_TYPE` for auto-indent [ci skip] 2023-10-11 10:37:40 +09:00
Nobuyoshi Nakada 47274ba8c1 Extract numparam nterms 2023-10-10 16:32:40 +09:00
Nobuyoshi Nakada 9095e712a3 Use `rb_node_exits_t` instead of `NODE` 2023-10-10 16:32:40 +09:00
Nobuyoshi Nakada e2998c42e1 Forward declaration of `struct RNode_DEF_TEMP` and its typedef 2023-10-10 16:32:40 +09:00
yui-knk 5245123a4b Remove not used fields from DEFN 2023-10-10 11:05:29 +09:00
Nobuyoshi Nakada a8d71535ff Pre-allocate `NODE_DEFN`/`NODE_DEFS` nodes
To fix the order of node IDs, for typeprof tests.
2023-10-10 00:09:52 +09:00
Nobuyoshi Nakada 4c00ab7fd6 Refactor NODE_DEF_TEMP
Use `NODE_DEF_TEMP` as the wrapper of `NODE_DEFS` in ripper, not only
of `NODE_DEFN`, so that `endless_method_name` works consistently.
2023-10-10 00:09:52 +09:00
yui-knk b9a2348632 Take care of internal node type
In parse.y, node can be NODE_DEF_TEMP or NODE_EXITS.
Hit "unknown node" without taking care of them.
For example `ruby --dump=y lib/cgi/util.rb` causes
"[BUG] unknown node: 107".
2023-10-09 12:38:32 +09:00
yui-knk b5d74f4f26 Remove not used fields from EVSTR 2023-10-08 16:34:32 +09:00
yui-knk 5810304c2e Remove not used fields from asgn nodes 2023-10-07 17:54:35 +09:00
yui-knk b7ee728a83 Correctly casting node for accessing nd_value and nd_vid in parse.y 2023-10-07 17:54:35 +09:00
yui-knk f28d380374 Pass nd_value to NODE_REQUIRED_KEYWORD_P 2023-10-07 17:54:35 +09:00
yui-knk b1a3c11c86 Use rb_node_masgn_t instead of NODE 2023-10-07 17:54:35 +09:00
yui-knk 5c779dc45d Remove not used fields from MATCH3 2023-10-06 15:32:33 +09:00
yui-knk 58fc45325f Remove not used fields from YIELD 2023-10-06 07:31:53 +09:00
yui-knk f6a2af255b Remove not used fields from ZLIST 2023-10-06 07:31:22 +09:00
Nobuyoshi Nakada a5cc6341c0
Remove `NODE_VALUES`
This node type was added for the multi-value experiment back in 2004.
The feature itself was removed after a few years, but this is its
remnant.
2023-10-06 03:39:58 +09:00
Nobuyoshi Nakada efa18fd6b3 Chain nodes to exit only 2023-10-05 14:23:42 +09:00
Nobuyoshi Nakada 5c82b9baed Do not chain unexpected node 2023-10-05 14:23:42 +09:00
Nobuyoshi Nakada f5f3b35b93 Remove unused nodes in NODE_RETURN and NODE_REDO 2023-10-05 14:23:42 +09:00
Nobuyoshi Nakada 70e1635950 Move internal NODE_DEF_TEMP to parse.y 2023-10-05 14:23:42 +09:00
yui-knk a472fd55da Remove not used fields from colon nodes 2023-10-05 13:19:09 +09:00
yui-knk 4a3f88f161 Fix cast type 2023-10-05 13:19:09 +09:00
yui-knk ed8a3428e4 Remove not used fields from variable nodes 2023-10-04 12:15:39 +09:00
Nobuyoshi Nakada 9059dfce12
`yield` cannot be placed outside methods even in blocks 2023-10-02 23:20:03 +09:00
yui-knk 4da04d5f43 Include new node types into %printer 2023-10-02 13:49:57 +09:00
yui-knk 81668579ed Remove not used fields from call nodes 2023-10-02 09:41:45 +09:00
yui-knk fdc329ea6f Correctly casting node for accessing nd_args in parse.y 2023-10-02 09:41:45 +09:00
yui-knk c1894a9d8b Use rb_node_fcall_t instead of NODE 2023-10-02 09:41:45 +09:00
yui-knk 50756a1f08 Use rb_node_block_pass_t instead of NODE 2023-10-01 19:38:03 +09:00
yui-knk 08239fd6af Use rb_node_args_t and rb_node_args_aux_t instead of NODE 2023-10-01 19:38:03 +09:00
yui-knk cecd1de2eb Use rb_node_opt_arg_t and rb_node_kw_arg_t instead of NODE 2023-10-01 09:19:42 +09:00
Nobuyoshi Nakada 1cedecebb8 Stop saving source locations unnecessarily
`node_newnode` and `parser_dispatch_delayed_token` do not use or
change `ruby_sourceline`.
2023-09-30 20:14:53 +09:00
Nobuyoshi Nakada 7592b07c28 Take line number from the tracked token location 2023-09-30 20:14:53 +09:00
yui-knk 4997903c20 Remove not used fields from FOR_MASGN 2023-09-30 19:17:28 +09:00
yui-knk 1fbccd02ee Remove not used fields from OP_ASGN_AND, OP_ASGN_OR 2023-09-30 18:53:40 +09:00
yui-knk eba19d86d4 Remove not used fields from HASH 2023-09-30 17:20:54 +09:00
yui-knk 97ac5deeec Remove not used fields from BEGIN 2023-09-30 17:20:16 +09:00
yui-knk 716a12902d Remove not used fields from ERROR 2023-09-30 17:02:50 +09:00
yui-knk db18428fff Remove not used fields from ITER, FOR 2023-09-30 16:30:57 +09:00
yui-knk 4c18615ffe Remove not used fields from MODULE, SCLASS 2023-09-30 16:24:43 +09:00
yui-knk 4e90be4c93 Remove not used fields from ONCE 2023-09-30 13:23:32 +09:00
yui-knk d293d9e191 Expand pattern_info struct into ARYPTN Node and FNDPTN Node 2023-09-30 13:11:32 +09:00
yui-knk 1b97c17e03 Remove not used fields from ARYPTN, FNDPTN 2023-09-30 13:11:32 +09:00
yui-knk 129d006852 Remove not used fields from argument nodes 2023-09-30 12:29:29 +09:00
yui-knk 83af0b9128 Remove not used fields from NTH_REF, BACK_REF 2023-09-30 12:28:06 +09:00