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

245 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada e5e1f9813e [Bug #19838] Flush delayed token nonconsecutive with the next token 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
Hiroshi SHIBATA 7149543f24
Added TestRipper namespace to test_call_colon2 2023-11-02 15:13:40 +09:00
lukeg 1925c6d555
test/ripper: nest helper classes under TestRipper module
Generic names like Node and NodeList should be namespaced properly.
2023-11-02 15:10:50 +09:00
Nobuyoshi Nakada 40efbc7e40 [Bug #19851] Ripper: Hide internal block argument ID 2023-08-26 02:08:53 +09:00
Peter Zhu 0b8f15575a Fix memory leak for incomplete lambdas
[Bug #19836]

The parser does not free the chain of `struct vtable`, which causes
memory leaks.

The following script reproduces this issue:

```
10.times do
  100_000.times do
    Ripper.parse("-> {")
  end

  puts `ps -o rss= -p #{$$}`
end
```
2023-08-09 14:06:58 -04:00
Peter Zhu 5bc8fceca8 Fix memory leak in parser for incomplete tokens
[Bug #19835]

The parser does not free the `tbl` of the `struct vtable` when there are
leftover `lvtbl` in the parser. This causes a memory leak.

The following script reproduces this issue:

```
10.times do
  100_000.times do
    Ripper.parse("class Foo")
  end

  puts `ps -o rss= -p #{$$}`
end
```
2023-08-09 14:06:58 -04:00
Peter Zhu 4b6c584023 Remove --disable-gems for assert_separately
assert_separately adds --disable=gems so we don't need to add
--disable-gems when calling assert_separately.
2023-08-03 09:11:08 +09:00
Nobuyoshi Nakada 382678d411 [Bug #19788] Use the result of `tCOLON2` event 2023-08-01 19:00:31 +09:00
Nobuyoshi Nakada 5c77402d88
Fix null pointer access in Ripper#initialize
In `rb_ruby_ripper_parser_allocate`, `r->p` is NULL between creating
`self` and `parser_params` assignment.  As GC can happen there, the
typed-data functions for it need to consider the case.
2023-07-16 15:41:10 +09:00
Peter Zhu 27d3fa2af0 Increase memory leak test timeout
The test times out on some platforms, so increase the timeout.
2023-06-28 13:47:48 -04:00
Peter Zhu a500eb9f8c Fix memory leak in Ripper
The following script leaks memory in Ripper:

```ruby
require "ripper"

20.times do
  100_000.times do
    Ripper.parse("")
  end

  puts `ps -o rss= -p #{$$}`
end
```
2023-06-28 09:50:51 -04:00
Nobuyoshi Nakada 6be402e172
[Bug #19736] Recover after unterminated interpolation 2023-06-20 20:10:46 +09:00
Nobuyoshi Nakada ac8a16237c
[Bug #19563] Yield words separators per lines
So that newlines across a here-doc terminator will be separated
tokens.

Cf. https://github.com/ruby/irb/pull/558
2023-04-07 23:13:56 +09:00
Kazuki Tsujimoto 4ac8d11724
`*` in an array pattern should not be parsed as nil in ripper
After 6c0925ba70, it was impossible
to distinguish between the presence or absence of `*`.

    # Before the commit
    Ripper.sexp('0 in []')[1][0][2][1]  #=> [:aryptn, nil, nil, nil, nil]
    Ripper.sexp('0 in [*]')[1][0][2][1] #=> [:aryptn, nil, nil, [:var_field, nil], nil]

    # After the commit
    Ripper.sexp('0 in []')[1][0][2][1]  #=> [:aryptn, nil, nil, nil, nil]
    Ripper.sexp('0 in [*]')[1][0][2][1] #=> [:aryptn, nil, nil, nil, nil]

This commit reverts it.
2023-04-01 16:35:24 +09:00
Nobuyoshi Nakada 040fab3782 Ripper: Add keyword options to `assert_parse_files` 2023-03-28 17:14:34 +09:00
Kazuki Tsujimoto d51529244f
[Bug #19175] p_kw without a sub pattern should be `assignable' 2023-03-26 18:57:34 +09:00
Kazuki Tsujimoto 6c0925ba70
[Bug #19175] p_rest should be `assignable'
It should also check for duplicate names.
2023-03-26 18:56:21 +09:00
Nobuyoshi Nakada fad48fefe1 [Bug #19399] Parsing invalid heredoc inside block parameter
Although this is of course invalid as Ruby code, allow to just parse
and tokenize.
2023-02-02 12:20:10 +09:00
Nobuyoshi Nakada 3becc4a105
[Bug #19291] Rewind to the previous line
When rewinding looking ahead after newline token, also reset the last
line string, the pointers to it, and the location, not only the line
number.
2023-01-02 16:12:08 +09:00
Nobuyoshi Nakada 1912bf5461
Adjut indent [ci skip] 2023-01-02 16:12:08 +09:00
Nobuyoshi Nakada ace2eee544
[Bug #18963] Separate string contents by here document terminator 2022-08-28 09:29:24 +09:00
Nobuyoshi Nakada 844a0edbae [Bug #18962] Do not read again once reached EOF
`Ripper::Lexer#parse` re-parses the source code with syntax errors
when `raise_errors: false`.

Co-Authored-By: tompng <tomoyapenguin@gmail.com>
2022-08-12 15:58:18 +09:00
Nobuyoshi Nakada 1a70973f75 ripper: Check if anonymous parameters defined [Bug #18828] 2022-06-14 20:41:41 +09:00
Nobuyoshi Nakada 6daec46014 ripper: refine test to show expected states 2021-12-14 20:06:51 +09:00
Shugo Maeda 7686776c05
Hash values should be omitted in Ripper results 2021-09-11 22:03:10 +09:00
Nobuyoshi Nakada 2aa6826e81 Extract the wrapped value when yydebug [Bug #18075] 2021-08-15 11:40:06 +09:00
Nobuyoshi Nakada 50a534a152 ripper: wrap endless method in bodystmt [Bug #17869] 2021-05-21 18:28:24 +09:00
Nobuyoshi Nakada 050bb06e66 ripper: assertions for rescue/ensure in method body 2021-05-21 18:28:24 +09:00
Kazuki Tsujimoto 21863470d9
Pattern matching pin operator against expression [Feature #17411]
This commit is based on the patch by @nobu.
2021-03-21 15:14:31 +09:00
Shugo Maeda a319c04818
Fix typo [ci skip] 2021-02-19 17:27:53 +09:00
Shugo Maeda 5de38c41ae
ripper: fix a bug of Ripper::Lexer with syntax error and heredoc [Bug #17644] 2021-02-19 16:40:29 +09:00
manga_osyo b84b253a69 Fix Ripper with heredoc. 2021-01-17 12:58:13 +09:00
Nobuhiro IMAI 7ff0e93f96
parse.y: handle "duplicated argument name" appropriately on ripper.y
refs: 733ed1e184
2021-01-09 13:33:33 +09:00
Nobuyoshi Nakada 733ed1e184 ripper: fix bad label parameter handling [Bug #17425] 2020-12-23 09:56:35 +09:00
Nobuhiro IMAI e33eb09b76 ripper: fix `#tok` on some error events [Bug 17345]
sorting alias target by event arity, and setup suitable `Elem` for error.
2020-12-19 17:32:39 +09:00
Nobuyoshi Nakada 47328ad217
Ripper: Fixed erred token on wrong alias [Bug #17345] 2020-12-16 21:08:33 +09:00
Nobuyoshi Nakada e0bdd54348 Ripper: Refined error callbacks [Bug #17345] 2020-12-15 21:36:23 +09:00
Nobuyoshi Nakada f5ca3ff4db
Store all kinds of syntax errors [Bug #17345] 2020-11-26 20:14:34 +09:00
Nobuyoshi Nakada 1df3896382
Removed a duplicate assertion 2020-11-26 20:03:38 +09:00
Nobuhiro IMAI 1800f3fa5c
Ripper.{lex,tokenize} return full tokens even if syntax error
yet another implements [Feature #17276]
2020-11-20 11:44:57 +09:00
Jeremy Evans cd0877a93e
Support raise_errors keyword for Ripper.{lex,tokenize,sexp,sexp_raw}
Implements [Feature #17276]
2020-11-17 21:15:50 -08:00
Nobuyoshi Nakada 79b242260b
ripper: Invalid pragma value warning 2020-11-02 22:49:42 +09:00
Nobuyoshi Nakada 52c630da00
Assoc pattern matching (#3703)
[Feature #17260] One-line pattern matching using tASSOC

R-assignment is rejected instead.
2020-10-26 18:00:24 +09:00
Takashi Kokubun 4a7dccf44f
Add a Ripper.lex test of :on_embexpr_end
This is a weird use case of Ripper.lex which I'm not sure is supposed to
be maintained, so I'm adding this test so that we can easily notice such
changes.

If we change the behavior, this will break the behavior of hamlit.gem v1
and code like https://github.com/haml/haml/pull/1043.
2020-10-19 20:56:09 -07:00
Nobuyoshi Nakada 4ed0c33d13
Prohibit setter method names in all kinds of endless methods
Also unwrap NODE_RIPPER to check the method name.
2020-10-12 00:40:55 +09:00
Nobuyoshi Nakada 3d8705dcfd
Drop token info for endless method definition
Because it does not have closing `end`.
2020-06-25 01:14:26 +09:00
Nobuyoshi Nakada 419b0596a2
[ripper] added endless method definition event tests 2020-06-25 01:14:18 +09:00
Nobuyoshi Nakada 263b941321
[ripper] fix mismatched indentations warning [Bug #16981]
The scanner location has to be set from `lex.ptok` before it is
flushed by dispatching the scanner event.
2020-06-24 19:53:14 +09:00