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

381 Коммитов

Автор SHA1 Сообщение Дата
Kevin Newton cd8d1018bb [ruby/prism] Resync RBI and test it in CI
https://github.com/ruby/prism/commit/4ef4032774
2024-02-29 16:29:16 +00:00
Koichi ITO f8dd2342bf [ruby/prism] Fix an incorrect parsing for `Prism::Translation::Parser`
This PR fixes an incorrect parsing for `Prism::Translation::Parser`
when one-line pattern mathing with Ruby 2.7 runtime.

## Expected

Parsing should be done based on the specified Ruby parsing version,
independent of the Ruby runtime version. When parsing for Ruby 3.3,
it should return `:match_pattern_p` node:

```console
$ ruby -rprism -rprism/translation/parser33 -ve 'p Prism::Translation::Parser33.parse("foo in bar")'
ruby 3.0.6p216 (2023-03-30 revision https://github.com/ruby/prism/commit/23a532679b) [x86_64-darwin19]
s(:match_pattern_p,
s(:send, nil, :foo),
  s(:match_var, :bar))
```

## Actual

When parsing with Ruby 2.7 runtime, `match_pattern` node is returned,
even though it is expected to parse for Ruby 3.3:

```console
$ ruby -rprism -rprism/translation/parser33 -ve 'p Prism::Translation::Parser33.parse("foo in bar")'
ruby 2.7.8p225 (2023-03-30 revision https://github.com/ruby/prism/commit/1f4d455848) [x86_64-darwin19]
s(:match_pattern,
s(:send, nil, :foo),
  s(:match_var, :bar))
```

The cause was the use of `RUBY_VERSION` for condition logic,
which made it dependent on runtime Ruby version.
`Prism::Translation::Parser` supports parsing for Ruby 3.3+.
Therefore, the condition for parsing Ruby 2.7, which is not supported, is being removed.

## Background

Found due to incompatibility with RuboCop's `Layout/SpaceAroundKeyword` and `Style/TernaryParentheses` cops.

https://github.com/ruby/prism/commit/e752e251d2
2024-02-29 16:06:40 +00:00
Koichi ITO 7c4bf61a35 [ruby/prism] Follow RuboCop's parser engine support
With the introduction of `Prism::Translation::Parser` to RuboCop (RuboCop AST),
the number of arguments for `RuboCop::AST::ProcessedSource#parser_class` internal API will be changed:
https://github.com/rubocop/rubocop-ast/pull/277

## Before

As a result, the following error will occur starting from the next release of RuboCop AST (< 1.30.0) :

```console
$ bundle exec ruby -rrubocop/ast -rprism -rprism/translation/parser/rubocop -ve \
"p RuboCop::AST::ProcessedSource.new('42', 80_82_73_83_77.33).ast"
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22]
/Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser/rubocop.rb:25:in `parser_class':
wrong number of arguments (given 2, expected 1) (ArgumentError)
        from /Users/koic/src/github.com/rubocop/rubocop-ast/lib/rubocop/ast/processed_source.rb:309:in `create_parser'
        from /Users/koic/src/github.com/rubocop/rubocop-ast/lib/rubocop/ast/processed_source.rb:219:in `parse'
        from /Users/koic/src/github.com/rubocop/rubocop-ast/lib/rubocop/ast/processed_source.rb:47:in `initialize'
        from -e:1:in `new'
        from -e:1:in `<main>'
```

## After

This PR prevents the above error by updating the monkey patch to support the new argument:

```console
$ bundle exec ruby -rrubocop/ast -rprism -rprism/translation/parser/rubocop -ve \
"p RuboCop::AST::ProcessedSource.new('42', 80_82_73_83_77.33).ast"
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22]
s(:int, 42)
```

Moreover, to ensure compatibility with the existing RuboCop AST, conditional logic
has been implemented to maintain backward compatibility.

https://github.com/ruby/prism/commit/8a6909f4d5
2024-02-27 20:09:42 +00:00
Kevin Newton 3ca8b4aee0 [ruby/prism] Support -p, -n, -a, and -l command line options
https://github.com/ruby/prism/commit/959eb506ca
2024-02-27 04:22:39 +00:00
Kevin Newton 1ce3d9acbf [ruby/prism] Fix xstring heredoc parser translator
https://github.com/ruby/prism/commit/4e0f703975
2024-02-26 14:48:17 +00:00
Kevin Newton 99d0f687fc [ruby/prism] Fix parser translator for pinned expression
https://github.com/ruby/prism/commit/eeae07193b
2024-02-26 14:35:00 +00:00
Kevin Newton af3145bb24 [ruby/prism] Handle negated numeric in parser translation
https://github.com/ruby/prism/commit/5877a95be4
2024-02-26 14:26:53 +00:00
Kevin Newton 804b2a3787 [ruby/prism] Rebase against main
https://github.com/ruby/prism/commit/813e20d449
2024-02-24 03:39:29 +00:00
Gopal Patel aa8841405b [ruby/prism] Less code modifications. More steep:ignore for now
https://github.com/ruby/prism/commit/7905bdbf83
2024-02-24 03:39:28 +00:00
Gopal Patel dfee033746 [ruby/prism] Replace awkward code changes with steep:ignore
Also remove RBS for currently ignored files. Will follow-up when those
check fully in later PRs.

https://github.com/ruby/prism/commit/2cae58f86d
2024-02-24 03:39:28 +00:00
Gopal Patel 66565e36ea [ruby/prism] Add documentation for Location#source!
https://github.com/ruby/prism/commit/467e1cc2c4
2024-02-24 03:39:26 +00:00
Gopal Patel 8fa1843523 [ruby/prism] Relax Location#source to be optional
https://github.com/ruby/prism/commit/9f00fe7510
2024-02-24 03:39:26 +00:00
Gopal Patel ca8a626586 [ruby/prism] Fix my RipperCompat logic mistake from expansion for steep flow analysis
https://github.com/ruby/prism/commit/f71a390c12
2024-02-24 03:39:25 +00:00
Gopal Patel 935d4fab62 [ruby/prism] Remove Ripper from public RBS, type-assert remaining issues
https://github.com/ruby/prism/commit/5fda7a0760
2024-02-24 03:39:23 +00:00
Gopal Patel 7556fd937c [ruby/prism] Split private types
https://github.com/ruby/prism/commit/0209d093ec
2024-02-24 03:39:22 +00:00
Gopal Patel 46fe3dc799 [ruby/prism] Fix IgnoredNewlineToken comparison of Ripper::Lexer::State
https://github.com/ruby/prism/commit/8c9502f61b
2024-02-24 03:39:20 +00:00
Gopal Patel b9b0712556 [ruby/prism] Use steep to type check RBS and Ruby files
https://github.com/ruby/prism/commit/eabed9f4fd
2024-02-24 03:39:19 +00:00
Kevin Newton ec6532b458 [ruby/prism] Add some encoding debugging to make testing easier
https://github.com/ruby/prism/commit/0c042561c6
2024-02-23 20:02:19 +00:00
Kevin Newton a38cc177d2 [ruby/prism] Duplicated when clauses
https://github.com/ruby/prism/commit/865b0d5fbe
2024-02-23 13:25:31 -05:00
Kevin Newton 5e0589cf52 [ruby/prism] Parse float values
https://github.com/ruby/prism/commit/9137226a52
2024-02-22 22:42:44 -05:00
Kevin Newton 3b3def5db7 [ruby/prism] Regenerate snapshots using integer values 2024-02-22 22:42:44 -05:00
Kevin Newton af0a6ea1d5 [ruby/prism] Add an IntegerField for parsing integer values
https://github.com/ruby/prism/commit/120d8c0479
2024-02-22 22:42:44 -05:00
Philip Mueller 3c61222d68 [ruby/prism] all constant nodes should have full_name and full_name_parts methods
https://github.com/ruby/prism/commit/792265ae0b
2024-02-22 21:43:02 +00:00
Noah Gibbs 551f64745f [ruby/prism] Allow skipping warnings as needed, and pass a reason through to Parser::Diagnostic
https://github.com/ruby/prism/commit/6a84a3c9fb
2024-02-21 22:38:48 +00:00
Noah Gibbs 45ae69e37e [ruby/prism] Update lib/prism/translation/parser.rb
https://github.com/ruby/prism/commit/c3cc282343

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-02-21 22:38:48 +00:00
Noah Gibbs e3b9eec349 [ruby/prism] Translation::Parser should process warnings, not just errors
https://github.com/ruby/prism/commit/ea7e400f85
2024-02-21 22:38:47 +00:00
Kevin Newton ae3e82a525 [ruby/prism] Fix up comment state
https://github.com/ruby/prism/commit/c6561becf0
2024-02-19 19:50:46 +00:00
Kevin Newton ea529dd409 [ruby/prism] Lazy methods for start and end offset on node
https://github.com/ruby/prism/commit/4510e2746d
2024-02-18 21:37:13 +00:00
Kevin Newton 792804e32f [ruby/prism] Split up comments between leading and trailing
Also make them lazy to allocate the array, and also expose ParseResult#encoding.

https://github.com/ruby/prism/commit/08ec7683ae
2024-02-18 20:57:13 +00:00
Kevin Newton 13301587cf [ruby/prism] Fix block_pass for []=
https://github.com/ruby/prism/commit/bf79206220
2024-02-16 20:41:52 +00:00
Noah Gibbs e801ccb343 [ruby/prism] More rescue and ensure; constant handling
https://github.com/ruby/prism/commit/207f579e70
2024-02-16 17:50:17 +00:00
Noah Gibbs 7d3e889bbb [ruby/prism] Move visit methods into a Ripper Compiler
https://github.com/ruby/prism/commit/44c4dc5268
2024-02-16 17:50:17 +00:00
Max Prokopiev f012ce0d18 [ruby/prism] Fix lexing of `foo!` when it's a first thing to parse
https://github.com/ruby/prism/commit/7597aca76a
2024-02-16 14:08:56 +00:00
Benoit Daloze 1b9b960963 [ruby/prism] Make location methods thread-safe
* Before it could result in NoMethodError if multiple threads were
  calling location methods: https://gist.github.com/eregon/b78b7f266d7ee0a278a389cfd1782232

https://github.com/ruby/prism/commit/ff762dcccd
2024-02-15 23:04:38 +00:00
Kevin Newton e7f7a85285
[PRISM] Sync prism version bump 2024-02-15 15:50:04 -05:00
Kevin Newton 14a7277da1 [ruby/prism] Speed up creating Ruby AST
When creating the Ruby AST, we were previously allocating Location
objects for every node and every inner location. Instead, this
commit changes it to pack both the start offset and length into a
single u64 and pass that into the nodes. Then, when the locations
are requested via a reader method, we lazily allocate the Location
objects.

https://github.com/ruby/prism/commit/de203dca83

Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
2024-02-15 20:39:50 +00:00
Kevin Newton 87cc2fd015 [ruby/prism] Fix up invalid syntax
https://github.com/ruby/prism/commit/8e3aad9e27
2024-02-15 20:36:48 +00:00
Noah Gibbs a5cee8fa79 [ruby/prism] Handle more aliases. Better testing of prism ripper CLI and a test for it.
https://github.com/ruby/prism/commit/cfd4f28cb3
2024-02-15 20:26:31 +00:00
Benoit Daloze 8f17b3bd27 [ruby/prism] Avoid extra String copies in the FFI backend
* For Prism.parse_file the file contents would be read as native, then
  converted to a Ruby String, then converted to a native String for
  pm_serialize_parse().
* Refactor the logic to always use a pm_string for the source code and
  pass that to other native functions.

https://github.com/ruby/prism/commit/9002b3c47d
2024-02-15 20:25:35 +00:00
Koichi ITO be82755d4a [ruby/prism] Support multi-versioning for `Prism::Translation::Parser`
## Summary

Fixes https://github.com/ruby/prism/pull/2356.

I'm working on integrating Prism into RuboCop.

This PR introduces `Prism::Translation::Parser33` and `Prism::Translation::Parser34`, named
in accordance with the following comments.
https://github.com/rubocop/rubocop/issues/12600#issuecomment-1932707748

Currently, `Prism::Translation::Parser` always operates in Ruby 3.4 mode.
This means it will not parse as Ruby 3.3 even if `TargetRubyVersion: 80_82_73_83_77.33` is specified.

Therefore, the `it` introduced in Ruby 3.4 is parsed incompatibly with Ruby 3.3. In Ruby 3.3,
the expected name for an `lvar` is `:it`, not `:"0it"`.

### Expected AST

The following is an expected AST when parsing Ruby 3.3 code:

```console
$ bundle exec ruby -rprism -rprism/translation/parser33 -ve "p Prism::Translation::Parser33.parse('items.map { it.do_something }')"
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22]
s(:block,
  s(:send,
    s(:send, nil, :items), :map),
  s(:args),
  s(:send,
    s(:send, nil, :it), :do_something))
```

### Actual AST

The following is an actual AST when parsing Ruby 3.3 code:

```console
$ ruby -rprism -ve "p Prism::Translation::Parser.parse('items.map { it.do_something }')"
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22]
s(:block,
  s(:send,
    s(:send, nil, :items), :map),
  s(:args),
  s(:send,
    s(:lvar, :"0it"), :do_something))
```

`Prism::Translation::Parser33` and `Prism::Translation::Parser34` aim to correspond to Ruby 3.3 and Ruby 3.4, respectively.

And, The hack of specifying `TargetRubyVersion: 80_82_73_83_77.33` is expected to become unnecessary in the future,
but the behavior will be maintained until RuboCop's support is finalized:
https://github.com/rubocop/rubocop/issues/12600#issuecomment-1933657732

## Additional Information

A private method named `convert_for_prism` is prepared to convert the `version` from Parser to the `version` expected by Prism.
For example, a Parser-compatible value is `3.3`, whereas Prism expects `"3.3.0"`.

`Parser#version` is not used in RuboCop, but it's unclear how it is utilized in other libraries that rely on the Parser gem.

Therefore, logic to maintain compatibility between Parser and Prism is implemented.

https://github.com/ruby/prism/commit/62d3991e22
2024-02-15 20:21:13 +00:00
Benoit Daloze c2d8d6eba6 Initialize the Prism::Source directly with all 3 fields for the C extension
* Faster that way:
  $ ruby -Ilib -rprism -rbenchmark/ips -e 'Benchmark.ips { |x| x.report("parse") { Prism.parse("1 + 2") } }'
  195.722k (± 0.5%) i/s
  rb_iv_set():
  179.609k (± 0.5%) i/s
  rb_funcall():
  190.030k (± 0.3%) i/s
  before this PR:
  183.319k (± 0.4%) i/s
2024-02-14 15:48:33 +00:00
Benoit Daloze 1b2708b123 [ruby/prism] Remove attr_writer's for ParseResult#start_line and #offsets
* As the user should not set these.
* Use #instance_variable_set/rb_iv_set() instead internally.

https://github.com/ruby/prism/commit/cace09fb8c
2024-02-14 15:48:33 +00:00
Benoit Daloze f0f6ffef42 [ruby/prism] Serialize the newline_list to avoid recomputing it again later
* Fixes https://github.com/ruby/prism/issues/2380

https://github.com/ruby/prism/commit/4eaaa90114
2024-02-14 15:48:32 +00:00
Kevin Newton 12b0e67fec
[PRISM] Sync to latest prism 2024-02-14 09:58:36 -05:00
Kevin Newton b1964a9204 [ruby/prism] Add code unit APIs to location
LSPs need this because the protocol dictates that you return code
units for offsets. None of our existing APIs provided that
information, and since we hid the source it's not nearly as useful
for them. Now they can pass an encoding directly to:

* Location#start_code_units_offset
* Location#end_code_units_offset
* Location#start_code_units_column
* Location#end_code_units_column

https://github.com/ruby/prism/commit/4757a2cc06

Co-Authored-By: Vinicius Stock <vinicius.stock@shopify.com>
2024-02-13 20:10:25 +00:00
Kevin Newton 29d04bb0c4 [ruby/prism] Introduce `version: "3.4.0"`
This is effectively an alias for "latest" right now. In the future
it will change to be its own enum value.

https://github.com/ruby/prism/commit/2c86036022
2024-02-13 18:26:28 +00:00
Vinicius Stock dedca31804 [ruby/prism] Fix `full_name` for constant path targets
https://github.com/ruby/prism/commit/84c10f3a2d
2024-02-13 14:09:19 +00:00
Kevin Newton 94bc5ad30a [ruby/prism] ruby_parser translator
https://github.com/ruby/prism/commit/1925b970c7
2024-02-12 17:54:54 +00:00
Noah Gibbs 16b39072a5 [ruby/prism] Move Prism::RipperCompat to Prism::Translation::Ripper
https://github.com/ruby/prism/commit/c0331abe4f
2024-02-12 15:57:57 +00:00
Noah Gibbs 8688256522 [ruby/prism] Update lib/prism/ripper_compat.rb
https://github.com/ruby/prism/commit/2c53e017c1

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-02-09 19:49:27 +00:00
Noah Gibbs f635b4dd0e [ruby/prism] RipperCompat: add array-refs, assigns, symbols, strings
https://github.com/ruby/prism/commit/b771c7f2ec
2024-02-09 19:49:27 +00:00
Kevin Newton cf1cd215c0 [ruby/prism] Significantly faster offset cache for parser
https://github.com/ruby/prism/commit/8cd92eef79
2024-02-09 16:27:05 +00:00
Noah Gibbs 1983949811 [ruby/prism] Looks like Symbol#name wasn't a thing in 2.7, so need to switch back to to_s
https://github.com/ruby/prism/commit/0b90c9a398
2024-02-08 16:02:06 +00:00
Noah Gibbs 0c73553052 [ruby/prism] Add Kevin's visit_all change and change the parent class to Compiler.
https://github.com/ruby/prism/commit/bbdba3f42d

Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
2024-02-08 16:02:06 +00:00
Noah Gibbs f8b8a6780c [ruby/prism] Update lib/prism/ripper_compat.rb
https://github.com/ruby/prism/commit/03addf2d3d

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-02-08 16:02:05 +00:00
Noah Gibbs 3f0aa55449 [ruby/prism] Update lib/prism/ripper_compat.rb
https://github.com/ruby/prism/commit/5eac08f699

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-02-08 16:02:05 +00:00
Noah Gibbs c1aba5d97b [ruby/prism] Update lib/prism/ripper_compat.rb
https://github.com/ruby/prism/commit/8271ce5ec9

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-02-08 16:02:05 +00:00
Noah Gibbs 70bc4ce34f [ruby/prism] Update lib/prism/ripper_compat.rb
https://github.com/ruby/prism/commit/6e2bf9c8cd

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-02-08 16:02:05 +00:00
Noah Gibbs 6aceb91de0 [ruby/prism] Update lib/prism/ripper_compat.rb
https://github.com/ruby/prism/commit/bce0a5c916

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-02-08 16:02:04 +00:00
Noah Gibbs 366af4679e [ruby/prism] RipperCompat: support for more features.
* add bin/prism ripper to compare Ripper output
* block arg handling is quirky, do it per-call-site
* block required params
* boolean values
* various assign-operator support
* breaks, early fragile begin/rescue/end
* more fixtures being checked

https://github.com/ruby/prism/commit/31732cb720
2024-02-08 16:02:04 +00:00
Kevin Newton 0e1f22ac7e [ruby/prism] Dev-only CLI
We keep adding more scripts to /bin that are doing the same kinds
of processing. Instead, this commit consolidates them all into a
single CLI that shares the same logic so that we can consistently
read files in the same way.

It keeps around 2 binstubs for bin/lex and bin/parse since those
are the most used and I'm sure people have built up muscle memory
for those. Those scripts are now just wrappers for forwarding to
bin/prism.

https://github.com/ruby/prism/commit/bddcb9bf17
2024-02-07 21:26:14 +00:00
Noah Gibbs 1b68b459ca [ruby/prism] Commit Kevin's suggestion to simplify grabbing the operator.
https://github.com/ruby/prism/commit/874ba7a1f4

Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
2024-02-07 19:42:14 +00:00
Noah Gibbs 5b7baa0486 [ruby/prism] More different block-call syntaxes, support more types of method calls
https://github.com/ruby/prism/commit/40cf114a24
2024-02-07 19:42:13 +00:00
Noah Gibbs 73d222e1ef [ruby/prism] Support &. calls and calling with blocks, test with fixtures
https://github.com/ruby/prism/commit/e346fa583a
2024-02-07 19:42:13 +00:00
Noah Gibbs b1310940e3 [ruby/prism] RipperCompat: support more kinds of method calls and operators.
Add tests. Start parsing some simpler fixture code.

https://github.com/ruby/prism/commit/997f4191d8
2024-02-07 19:42:13 +00:00
Kevin Newton fcc8df622a
Bump prism version 2024-02-07 13:36:06 -05:00
Kevin Newton aad3c36bdf [ruby/prism] Support for Ruby 2.7
https://github.com/ruby/prism/commit/1a15b70a8e
2024-02-07 16:54:34 +00:00
Kevin Newton 164c18af7b [ruby/prism] Correct handle recover parameters on tokenize for parser translation
https://github.com/ruby/prism/commit/63979de21d
2024-02-07 14:44:36 +00:00
Kevin Newton 2dba441397 [ruby/prism] Even more ripper compat
https://github.com/ruby/prism/commit/47a602dc1c
2024-02-07 03:21:02 +00:00
Noah Gibbs e34505c631 [ruby/prism] More visitors and tests for RipperCompat
Part of issue #2354

https://github.com/ruby/prism/commit/cb28edae34
2024-02-07 01:49:54 +00:00
eileencodes 936c0ab5e8 [ruby/prism] Implement file parsing error handling
This PR implements proper file parsing error handling. Previously
`file_options` would call `pm_string_mapped_init` which would print an
error from `perror`. However this wouldn't raise a proper Ruby error so
it was just a string output. I've done the following:

- Raise an error from `rb_syserr_fail` with the filepath in
`file_options`.
- No longer return `Qnil` if `file_options` returns false (because now
it will raise)
- Update `file_options` to return `static void` instead of `static
bool`.
- Update `file_options` and `profile_file` to check the type so when
passing `nil` we see a `TypeError`.
- Delete `perror` from `pm_string_mapped_init`
- Update `FFI` backend to raise appropriate errors when calling
`pm_string_mapped_init`.
- Add tests for `dump_file`, `lex_file`, `parse_file`,
`parse_file_comments`, `parse_lex_file`, and `parse_file_success?`
when a file doesn't exist and for `nil`.
- Updates the `bin/parse` script to no longer raise it's own
`ArgumentError` now that we raise a proper error.

Fixes: ruby/prism#2207

https://github.com/ruby/prism/commit/b2f7494ff5
2024-02-06 20:49:33 +00:00
Kevin Newton 0b5be2f9e9 Sync to latest prism 2024-02-05 11:07:07 -05:00
Kevin Newton d2f004cf6a [ruby/prism] Fix hash pairs in patterns
https://github.com/ruby/prism/commit/b7ab29daa0
2024-02-02 21:16:04 +00:00
Kevin Newton 420a6349ec [ruby/prism] Small fixes for the parser translator
https://github.com/ruby/prism/commit/4327051c86
2024-02-02 13:36:23 -05:00
Kevin Newton e9f1324464 Sync to latest prism 2024-02-01 12:52:16 -05:00
Kevin Newton 731367d0ab [ruby/prism] Fix up CI
https://github.com/ruby/prism/commit/224ea85565
2024-01-30 18:45:19 +00:00
Aaron Patterson 8e708e4a07 Update forwarding locals for prism 2024-01-30 13:19:06 -05:00
Kevin Newton e050097beb [ruby/prism] Raise diagnostics for parser
https://github.com/ruby/prism/commit/102b4a16f5
2024-01-29 16:09:47 +00:00
Kevin Newton e256d44f98 [ruby/prism] Handle implicit rest in array pattern for parser gem
https://github.com/ruby/prism/commit/d3722d6660
2024-01-28 01:10:47 +00:00
Kevin Newton f12ebe1188 [ruby/prism] Add parser translation
https://github.com/ruby/prism/commit/8cdec8070c
2024-01-27 19:59:42 +00:00
Kevin Newton e337c9478a [ruby/prism] Error follow-up
Split up the diagnostic levels so that error and warning levels
aren't mixed. Also fix up deconstruct_keys implementation.

https://github.com/ruby/prism/commit/bd3eeb308d

Co-authored-by: Benoit Daloze <eregontp@gmail.com>
2024-01-27 18:46:16 +00:00
Benoit Daloze c2e2d2398b [ruby/prism] Call #inspect on diagnostic levels
* So it's clear it is a Symbol.
  Before:
  ... @level=warning_verbose_true>
  After:
  ... @level=:warning_verbose_true>

https://github.com/ruby/prism/commit/84503643b9
2024-01-27 18:41:07 +00:00
Kevin Newton 5d9d07a491 [ruby/prism] Bring back #arg_rest local
https://github.com/ruby/prism/commit/9b6907b727
2024-01-27 14:13:35 +00:00
Benoit Daloze de135bc247 [ruby/prism] Add level to warnings and errors to categorize them
* Fixes https://github.com/ruby/prism/issues/2082

https://github.com/ruby/prism/commit/7a74576357
2024-01-26 21:34:34 +00:00
Kevin Newton ebf803aa19 [ruby/prism] Fix Ruby head build
https://github.com/ruby/prism/commit/149e2ff7f6
2024-01-25 13:58:07 +00:00
Adam Hess ac4046d34b [ruby/prism] switch unless to if
https://github.com/ruby/prism/commit/29bdbf4212

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-01-19 22:57:46 +00:00
Adam Hess cfabe9c51c [ruby/prism] Handle stovetop start in constant path fullname
https://github.com/ruby/prism/commit/3a216e63fe
2024-01-19 22:57:45 +00:00
Kevin Newton da521fc92c [ruby/prism] Parsing rules document
https://github.com/ruby/prism/commit/57a9575543
2024-01-19 16:12:25 +00:00
Matthew Healy a58e091686 [ruby/prism] Extract identifier lexing documentation to separate file
https://github.com/ruby/prism/commit/c9df17e3c0
2024-01-19 15:43:29 +00:00
Cameron Dutro 8cbba87ca8 [ruby/prism] Add parse options to JavaScript's parsePrism function
https://github.com/ruby/prism/commit/d7fe7c7ae7
2024-01-16 19:19:30 +00:00
Kevin Newton d124124c16 [ruby/prism] Fix up gemspec
https://github.com/ruby/prism/commit/82e3126762
2024-01-16 19:01:36 +00:00
Jemma Issroff 8bf12d7b2f [ruby/prism] First pass at documenting information about the CRuby compiler
https://github.com/ruby/prism/commit/b575914b2f
2024-01-16 18:47:48 +00:00
Aaron Patterson 881c5a1846 [ruby/prism] Add a "repeated flag" to parameter nodes
It's possible to repeat parameters in method definitions like so:

```ruby
def foo(_a, _a)
end
```

The compiler needs to know to adjust the local table size to account for
these duplicate names.  We'll use the repeated parameter flag to account
for the extra stack space required

https://github.com/ruby/prism/commit/b443cb1f60

Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
Co-Authored-By: Jemma Issroff <jemmaissroff@gmail.com>
2024-01-10 15:24:26 +00:00
Kevin Newton 80da9b1547 [ruby/prism] Clarify __END__ comment
https://github.com/ruby/prism/commit/3e36d5eabc
2024-01-09 19:02:26 +00:00
Kevin Newton 3a3fcf56d0 [ruby/prism] Fix rational when parsing non decimal integer
https://github.com/ruby/prism/commit/75d4331f7f
2024-01-03 17:18:02 +00:00
Kevin Newton 23beceedb7 [ruby/prism] IndexTargetNode should always have ATTRIBUTE_WRITE
Because this is a user-facing change, we also need to deal with the
fact that CRuby 3.3.0 was just released.

In order to support workflows that want to parse exactly as CRuby
parses in a specific version, this PR introduces a new option to
the options struct that is "version". This allows you to specify
that you want "3.3.0" parsing.

I'm not sure if this is the correct solution. Another solution is
to just fork and keep around the old branch for security patches.
Or we could keep around a copy of the source files within this
repository as another directory and only update when necessary.
There are a lot of potential solutions here.

Because this change is so small and the check for it is so minimal,
I've decided to go with this enum. If this ends up entirely
cluttering the codebase with version checks, we'll come up with
another solution. But for now this works, so we're going to go in
this direction for a bit until we determine it's no longer working.

https://github.com/ruby/prism/commit/d8c7e6bd10
2024-01-02 18:51:18 +00:00
Kevin Newton 8bbe835cd8
Bump prism to version 0.19.0 2023-12-14 15:06:09 -05:00
Kevin Newton fe6ee5e921 [ruby/prism] Move flag position consistently to front
https://github.com/ruby/prism/commit/6e69a81737
2023-12-06 20:50:02 +00:00
Kevin Newton ea9f89eeb6 [ruby/prism] Ripper compat docs update
https://github.com/ruby/prism/commit/5f70b32b02
2023-12-04 17:00:14 +00:00
Kevin Newton 492c82cb41 [ruby/prism] Prism.parse_success?(source)
A lot of tools use Ripper/RubyVM::AbstractSyntaxTree to determine
if a source is valid. These tools both create an AST instead of
providing an API that will return a boolean only.

This new API only creates the C structs, but doesn't bother
reifying them into Ruby/the serialization API. Instead it only
returns true/false, which is significantly more efficient.

https://github.com/ruby/prism/commit/7014740118
2023-12-01 20:53:34 +00:00
Kevin Newton ec83bd7356 [ruby/prism] Provide heredoc? queries
https://github.com/ruby/prism/commit/e148e8fe6a
2023-12-01 18:46:52 +00:00
Kevin Newton cdb74d74af [ruby/prism] Change numbered parameters
Previously numbered parameters were a field on blocks and lambdas
that indicated the maximum number of numbered parameters in either
the block or lambda, respectively. However they also had a
parameters field that would always be nil in these cases.

This changes it so that we introduce a NumberedParametersNode that
goes in place of parameters, which has a single uint8_t maximum
field on it. That field contains the maximum numbered parameter in
either the block or lambda.

As a part of the PR, I'm introducing a new UInt8Field type that
can be used on nodes, which is just to make it a little more
explicit what the maximum values can be (the maximum is actually 9,
since it only goes up to _9). Plus we can do a couple of nice
things in serialization like just read a single byte.

https://github.com/ruby/prism/commit/2d87303903
2023-12-01 12:03:09 -05:00
Martin Emde cbe57caa24 [ruby/prism] Fix comments after HEREDOCs again.
The problem was deeper than just looking back a single token.
You can push the heredoc_end token way back into the list.
We need to save the last location of a heredoc end to see if
it's the last token in the file.

Fixes https://github.com/ruby/prism/pull/1954

https://github.com/ruby/prism/commit/91dfd4eecd
2023-12-01 15:17:20 +00:00
Kevin Newton abb1fe2868 [PRISM] Consolidate prism encoding files 2023-11-30 21:37:56 -05:00
Kevin Newton 10d3897e13 [PRISM] Big5 encodings 2023-11-30 21:37:56 -05:00
Kevin Newton 7b5bb978fb [PRISM] Alias CP51932 to EUC-JP 2023-11-30 21:37:56 -05:00
Kevin Newton 9ba92327f2 [PRISM] Consolidate SJIS encodings 2023-11-30 21:37:56 -05:00
Martin Emde aac8be8034 [ruby/prism] Fix lex_compat for `<<HEREDOC # comment` at EOF
Fixes https://github.com/ruby/prism/pull/1874

https://github.com/ruby/prism/commit/304dd78dd2
2023-11-30 14:10:04 +00:00
Matt Boldt 9fc40d2b26 [ruby/prism] Add MacJapanese encoding
MacJapanese (also aliased as MacJapan) is a modified Shift_JIS
encoding, but is implemented identically in Ruby

https://github.com/ruby/prism/commit/9e0a097699
2023-11-29 12:08:15 -05:00
Dhaval 9fada99cb2 [ruby/prism] added CP950 encoding
https://github.com/ruby/prism/commit/9c2d1cf4ba
2023-11-29 11:15:50 -05:00
Kevin Newton 4938390177 [ruby/prism] Implicit rest nodes
Fundamentally, `foo { |bar,| }` is different from `foo { |bar, *| }`
because of arity checks. This PR introduces a new node to handle
that, `ImplicitRestNode`, which goes in the `rest` slot of parameter
nodes instead of `RestParameterNode` instances.

This is also used in a couple of other places, namely:

* pattern matching: `foo in [bar,]`
* multi target: `for foo, in bar do end`
* multi write: `foo, = bar`

Now the only splat nodes with a `NULL` value are when you're
forwarding, as in: `def foo(*) = bar(*)`.

https://github.com/ruby/prism/commit/dba2a3b652
2023-11-28 22:33:50 +00:00
Kevin Newton c798943a4a [ruby/prism] Move DATA parsing into its own parse result field
https://github.com/ruby/prism/commit/42b60b6e95
2023-11-28 13:25:48 +00:00
Kevin Newton 1f06d168ba [ruby/prism] Add new doc to gemspec
https://github.com/ruby/prism/commit/99dfca6c1d
2023-11-22 15:15:07 +00:00
heyogrady e3ef05a434 [ruby/prism] Add `CP949` encoding
https://github.com/ruby/prism/commit/9e78dfdf69
2023-11-22 09:12:35 -05:00
Benoit Daloze 018e6abf85 [ruby/prism] Move CallNode#name field between receiver and arguments
* The same order as in source code.
* CallOrWriteNode, CallOperatorWriteNode, CallAndWriteNode already have
  the correct order so it was also inconsistent with them.

https://github.com/ruby/prism/commit/4434e4bc22
2023-11-22 12:15:20 +00:00
Kevin Newton 7d6f812c31 [ruby/prism] Update to v0.18.0
https://github.com/ruby/prism/commit/1398879d79
2023-11-21 13:59:10 -05:00
Vinicius Stock 7a9bb6d2a7 [ruby/prism] Fix constant path full name when parent is not a
constant
(https://github.com/ruby/prism/pull/1742)

* Raise if constant path parts contains nodes that can't be used to build full name

* Fix typo in constant path error documentation

Co-authored-by: Tim Morgan <tim@timmorgan.org>

---------

https://github.com/ruby/prism/commit/d73a053262

Co-authored-by: Tim Morgan <tim@timmorgan.org>
2023-11-21 16:39:27 +00:00
Haldun Bayhantopcu 8966d06b96 [ruby/prism] Warning for ENDs in methods
(https://github.com/ruby/prism/pull/1899)

https://github.com/ruby/prism/commit/1b41c2d56c
2023-11-21 16:36:12 +00:00
Ryan Garver e16ff17374 Rename the big5-hkscs stuff to something more generic and add UAO sharing common code.
Merge the Big5 extensions into pm_big5.c
2023-11-20 21:18:31 -05:00
Kevin Newton f2ed7eaba0 [ruby/prism] Add character APIs for locations
(https://github.com/ruby/prism/pull/1809)

https://github.com/ruby/prism/commit/d493ccd093
2023-11-20 16:07:06 +00:00
Ryan Garver cd4316a51f [ruby/prism] Big5 HKSCS encoding
https://github.com/ruby/prism/commit/3ca9823eb4
2023-11-18 13:52:17 -05:00
Maple Ong d976e7cc4b [ruby/prism] Update gemspec
https://github.com/ruby/prism/commit/1a10f6f9c0
2023-11-16 17:13:17 +00:00
Kevin Newton d2e7a70ee6 [ruby/prism] Track the then keyword for conditionals
https://github.com/ruby/prism/commit/fef0019a25
2023-11-15 23:08:11 +00:00
Kevin Newton ed75518192
[ruby/prism] Rename librubyparser to libprism
librubyparser was an artifact of the prototype that was initially
named ruby-parser. Instead, this renames it to libprism to be
consistent with the actual name.

https://github.com/ruby/prism/commit/8600b06811
2023-11-14 16:22:03 -05:00
Kevin Newton 94f82a65f7 [ruby/prism] Add the ability to convert nodes to dot
https://github.com/ruby/prism/commit/3e4b4fb947
2023-11-12 02:53:33 +00:00
Kevin Newton 85db7baccb [ruby/prism] Remove extra locals added by ...
https://github.com/ruby/prism/commit/b7850f2d30
2023-11-10 21:50:12 +00:00
Mateus Pereira 03aa1092ad [ruby/prism] Add source code and changelog uris
https://github.com/ruby/prism/commit/33a85f7867
2023-11-10 21:49:27 +00:00
Kevin Newton 201853f4e1 [ruby/prism] Provide Parameters#signature for mirroring Method#parameters
https://github.com/ruby/prism/commit/90b3245528
2023-11-08 22:17:43 +00:00
Kevin Newton 5a132c7864
Update prism to v0.17.1 2023-11-03 13:59:07 -04:00
Kevin Newton c44c982c93
[ruby/prism] Bump to version 0.17.0
https://github.com/ruby/prism/commit/61a306cd5c
2023-11-03 11:17:37 -04:00
Kevin Newton 47163f9cf9 [ruby/prism] Rename suppress warnings to verbose
https://github.com/ruby/prism/commit/fbb30216ca
2023-11-03 14:54:13 +00:00
Kevin Newton 4b5f516f2e [ruby/prism] Split comment
We were previously holding a type field on Comment to tell what
kind of comment it was. Instead, let's just use actual classes for
this.

https://github.com/ruby/prism/commit/e76830ca6e
2023-11-03 14:35:08 +00:00
Kevin Newton 8587d9a8bf
[ruby/prism] Wire up options through the Java parser
https://github.com/ruby/prism/commit/13fa262669
2023-11-03 10:13:50 -04:00
Kevin Newton d7d3243364
[ruby/prism] Properly support the start line option
https://github.com/ruby/prism/commit/33cc75a4b7
2023-11-03 10:13:50 -04:00
Kevin Newton 6496591194
[ruby/prism] Rename serialization APIs for consistency
https://github.com/ruby/prism/commit/5a2252e3ac
2023-11-03 10:13:49 -04:00
Kevin Newton 05f5c545d2
[ruby/prism] Wire up options through the FFI API
https://github.com/ruby/prism/commit/f0aa8ad93b
2023-11-03 10:13:49 -04:00
Kevin Newton ca7297efd3
[ruby/prism] Wire up options through the Ruby API
https://github.com/ruby/prism/commit/8582d372a3
2023-11-03 10:13:49 -04:00
Kevin Newton 2a0f2b7763
[ruby/prism] Create an options struct for passing all of the possible options
https://github.com/ruby/prism/commit/99e81619de
2023-11-03 10:13:49 -04:00
Kevin Newton 90b21b864d [prism] Updates for sync 2023-11-01 13:10:29 -04:00
Kevin Newton 493439c9ce [ruby/prism] Documentation for pm_strncasecmp
https://github.com/ruby/prism/commit/26934263b7
2023-11-01 13:10:29 -04:00
Kevin Newton 4490979615 [ruby/prism] Finish Ruby documentation
https://github.com/ruby/prism/commit/dfdcc98a3c
2023-11-01 13:10:29 -04:00
Kevin Newton 79034fbd50 [ruby/prism] More Ruby docs
https://github.com/ruby/prism/commit/ca9a660f52
2023-11-01 13:10:29 -04:00
Kevin Newton 953138698e [ruby/prism] Docs for node.rb and parse_result.rb
https://github.com/ruby/prism/commit/085da4feb9
2023-11-01 13:10:29 -04:00
Kevin Newton f12617ec98 [ruby/prism] Fix up Prism and Debug docs
https://github.com/ruby/prism/commit/c2b7724d91
2023-11-01 13:10:29 -04:00
Jemma Issroff e80ca70b9b [ruby/prism] Flip incorrect names of OptionalKeywordParameterNode and RequiredKeywordParameterNode
https://github.com/ruby/prism/commit/c31f61e898
2023-11-01 14:40:45 +00:00
Jemma Issroff d0625099e0 [ruby/prism] Split KeywordParameterNode into Optional and Required
Prior to this commit, KeywordParameterNode included both optional
and required keywords. With this commit, it is split in two, with
`OptionalKeywordParameterNode`s no longer having a value field.

https://github.com/ruby/prism/commit/89084d9af4
2023-11-01 14:40:44 +00:00
Kevin Newton b413760d66
[prism] Update prism to latest 2023-10-30 12:35:39 -04:00
Kevin Newton 7bf3d9343f [ruby/prism] parse_inline_comments -> parse_comments
https://github.com/ruby/prism/commit/bd4d248fd6
2023-10-30 15:53:37 +00:00
Kevin Newton c201dbc0ad [ruby/prism] Prism.parse_inline_comments
https://github.com/ruby/prism/commit/5b72f84480
2023-10-27 18:09:14 +00:00
Vinicius Stock 7e4d2bb81d [ruby/prism] Move static annotations into _static files
https://github.com/ruby/prism/commit/9a6d735890
2023-10-27 13:45:53 +00:00
Vinicius Stock 544f64075b [ruby/prism] Add RBI and RBS templates for Prism
https://github.com/ruby/prism/commit/b62305ff3e

Co-authored-by: Stan Lo <st0012@users.noreply.github.com>
2023-10-27 13:45:52 +00:00
Kevin Newton a40e2b8ee9 [ruby/prism] Fix parsing lone assoc splat within hash patterns
https://github.com/ruby/prism/commit/1da5e05672
2023-10-27 02:09:33 +00:00
Kevin Newton 21dc64534b [ruby/prism] Regenerate snapshots
https://github.com/ruby/prism/commit/160df9a687
2023-10-26 15:19:52 -04:00
Kevin Newton d1bb858d47 [ruby/prism] Match existing Ruby prettyprint
https://github.com/ruby/prism/commit/6d8358c083
2023-10-26 15:19:43 -04:00
Kevin Newton 6241cfab74
[prism] handle locals consistently 2023-10-26 15:08:31 -04:00
Kevin Newton 018f0a9c5f [ruby/prism] Rename to lefts/rights
https://github.com/ruby/prism/commit/e6deed05a5
2023-10-26 14:59:13 -04:00
Kevin Newton 922f48f081 [ruby/prism] Remove RequiredDestructuredParameterNode in favor of MultiTargetNode
https://github.com/ruby/prism/commit/6d1858192e
2023-10-26 14:59:07 -04:00
Jemma Issroff 7e4ee92de2 [ruby/prism] Add KeywordSplat flag to ArgumentsNode
Method calls with keyword splat args compile differently than
without since they merge the keyword arg hash with the keyword splat
hash. We know this information at parse time, so can set a flag
which the compiler can use.

https://github.com/ruby/prism/commit/e5f8a9a3cd
2023-10-26 18:47:50 +00:00
Kevin Newton 51ea82a770 [ruby/prism] Expose options on match last line nodes
https://github.com/ruby/prism/commit/0284b38861
2023-10-26 13:58:40 +00:00
Kevin Newton feb1427ad8 [ruby/prism] Compile with WASI
https://github.com/ruby/prism/commit/73c44b0b9c
2023-10-26 13:33:22 +00:00
Mau Magnaguagno f20e91fbf7 [ruby/prism] Avoid String#chars in DedentingHeredoc#to_a
Prefer String#[] directly.

https://github.com/ruby/prism/commit/916f991220
2023-10-23 14:56:18 +00:00
Matt Valentine-House 62e340251b Don't add anonymous locals when ISEQ binary debug is on 2023-10-19 16:57:43 +01:00
Kevin Newton 6873f96abc [ruby/prism] Bump to version 0.15.1
https://github.com/ruby/prism/commit/d906a8ceba
2023-10-18 19:19:38 +00:00
Kevin Newton 0f1e040068 [ruby/prism] Bump to version 0.15.0
https://github.com/ruby/prism/commit/ee429f8d50
2023-10-18 16:49:58 +00:00
Kevin Newton 8210cc4218 [ruby/prism] Fix lex compat when dedent should be 0
https://github.com/ruby/prism/commit/41c0e0e06e
2023-10-18 16:09:16 +00:00
Kevin Newton c82b10bbc3 [ruby/prism] Modify less of the CRuby locals
https://github.com/ruby/prism/commit/aca24b3a17
2023-10-18 16:08:32 +00:00
Kevin Newton 5d0604366e [ruby/prism] Add * and & to methods with ...
https://github.com/ruby/prism/commit/e8114a786a
2023-10-18 16:08:31 +00:00
Kevin Newton 5523a23469 [ruby/prism] Attach magic comments to the parse result
https://github.com/ruby/prism/commit/c7ef25a79a
2023-10-16 15:40:19 -07:00
Mau Magnaguagno 55a0d2c63b [ruby/prism] Avoid unnecessary delete_prefix in LibRubyParser.resolve_type
Only remove const prefix from non-pointer types.

https://github.com/ruby/prism/commit/97c9ffeb42
2023-10-16 10:39:44 +00:00
Mau Magnaguagno f6564fdd37 [ruby/prism] Simplify DedentingHeredoc#to_a
Move common ``results << token`` outside case-when.

https://github.com/ruby/prism/commit/84d0722ee9
2023-10-13 21:11:07 +00:00
Kevin Newton e700582d98 [ruby/prism] Bump version to 0.14.0
https://github.com/ruby/prism/commit/1731bf4520
2023-10-13 19:45:37 +00:00
Kevin Newton 11e946da2f [ruby/prism] Fix up PR failings
https://github.com/ruby/prism/commit/11255f636e
2023-10-13 15:31:30 -04:00
Kevin Newton 37d958eaf4 Remove old unescaping code 2023-10-13 15:31:30 -04:00
Vinicius Stock 69b024d7cc [ruby/prism] Add full_name to ConstantPathNode and ConstantPathTargetNode
https://github.com/ruby/prism/commit/b390553028
2023-10-06 01:57:34 +00:00
gazayas 488c0ed051 [ruby/prism] Remove trailing parenthesis in Location#pretty_print
https://github.com/ruby/prism/commit/8eaa199a28
2023-10-04 17:00:09 +00:00
BurdetteLamar 1943ea06a6 [ruby/prism] [DOC] Link fix
https://github.com/ruby/prism/commit/472bdc4d70
2023-10-02 13:22:53 +00:00
Kevin Newton 49d3bbe13b [ruby/prism] Add a logo
https://github.com/ruby/prism/commit/d87607b874
2023-09-29 15:39:24 +00:00
Kevin Newton be63e2515b [ruby/prism] Bump version
https://github.com/ruby/prism/commit/3e44415ca2
2023-09-29 15:21:50 +00:00
Kevin Newton 3d0a46796b Rename YARP symbols to prism 2023-09-27 13:57:38 -04:00
Kevin Newton 4f73a7c2f7 Sync to prism rename commits 2023-09-27 13:57:38 -04:00
Kevin Newton 8ab56869a6 Rename YARP filepaths to prism filepaths 2023-09-27 13:57:38 -04:00