Commit graph

36 commits

Author SHA1 Message Date
Kevin Newton
e9f1324464 Sync to latest prism 2024-02-01 12:52:16 -05: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.

bd3eeb308d

Co-authored-by: Benoit Daloze <eregontp@gmail.com>
2024-01-27 18:46:16 +00:00
Benoit Daloze
de135bc247 [ruby/prism] Add level to warnings and errors to categorize them
* Fixes https://github.com/ruby/prism/issues/2082

7a74576357
2024-01-26 21:34:34 +00:00
Kevin Newton
e00f42e5d3 [ruby/prism] Return 1-indexed line numbers
ad17f58729
2024-01-22 16:13:36 +00:00
Andrew Konchin
b2c12bfddb [ruby/prism] Document order of scopes in parsing options
908e92a695
2024-01-17 19:35:14 +00:00
Kevin Newton
6ff9f1aa51 [ruby/prism] Provide ability to format errors
27985b0e7e
2024-01-11 18:36:32 +00:00
Kevin Newton
165deec5fe [ruby/prism] Document the version option on prism parse
eddd72a8ef
2024-01-02 18:59:26 +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.

d8c7e6bd10
2024-01-02 18:51:18 +00:00
Kevin Newton
10bc0bd4ab [ruby/prism] Remove warnings check from parse_success? method
e30a241fb3
2023-12-07 14:39:11 +00:00
Kevin Newton
82f18baa21 [ruby/prism] Provide flags for changing encodings
e838eaff6f
2023-12-06 14:23:38 -05:00
Lily Lyons
1227b6d912 [ruby/prism] Refactor pm_diagnostic_t and pm_comment_t to use pm_location_t
115b6a2fc6
2023-12-04 14:33:44 +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.

7014740118
2023-12-01 20:53:34 +00:00
Kevin Newton
e2bbbacc23 [ruby/prism] Correctly pass around const pm_encoding_t *
ce4c67fb3a
2023-11-30 21:37:56 -05:00
Jean Boussier
2af82e2316 [ruby/prism] Convert start line to signed integers
Ruby allows for 0 or negative line start, this is often used
with `eval` calls to get a correct offset when prefixing a snippet.

e.g.

```ruby
caller = caller_locations(1, 1).first
class_eval <<~RUBY, caller.path, caller.line - 2
  # frozen_string_literal: true
  def some_method
    #{caller_provided_code_snippet}
  end
RUBY
```

0d14ed1452
2023-11-29 13:56:19 +00:00
Kevin Newton
c798943a4a [ruby/prism] Move DATA parsing into its own parse result field
42b60b6e95
2023-11-28 13:25:48 +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.

8600b06811
2023-11-14 16:22:03 -05:00
Kevin Newton
cc9bcad79c [ruby/prism] Make old compilers happy
145a67d1c3
2023-11-03 15:47:22 +00:00
Kevin Newton
47163f9cf9 [ruby/prism] Rename suppress warnings to verbose
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.

e76830ca6e
2023-11-03 14:35:08 +00:00
Kevin Newton
ec86b2eb39
[prism] Update to use new options APIs 2023-11-03 10:13:50 -04:00
Kevin Newton
e121efd835
[ruby/prism] Wire up the options through JavaScript
81a9b2817f
2023-11-03 10:13:50 -04:00
Kevin Newton
d7d3243364
[ruby/prism] Properly support the start line option
33cc75a4b7
2023-11-03 10:13:50 -04:00
Kevin Newton
05f5c545d2
[ruby/prism] Wire up options through the FFI API
f0aa8ad93b
2023-11-03 10:13:49 -04:00
Kevin Newton
ca7297efd3
[ruby/prism] Wire up options through the Ruby API
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
99e81619de
2023-11-03 10:13:49 -04:00
Kevin Newton
3551abab06 [ruby/prism] Fix up lint
77d4056766
2023-11-01 13:10:29 -04:00
Kevin Newton
8302f9986c [ruby/prism] Documentation for pm_string_t
ff1d2ec579
2023-11-01 13:10:29 -04:00
Kevin Newton
73b6934cf2 [ruby/prism] Fix up extension docs
cfd4431c3e
2023-11-01 13:10:29 -04:00
Kevin Newton
7bf3d9343f [ruby/prism] parse_inline_comments -> parse_comments
bd4d248fd6
2023-10-30 15:53:37 +00:00
Kevin Newton
df10e10314 [ruby/prism] Parse inline comments
44090d9f26
2023-10-27 18:09:14 +00:00
Kevin Newton
d1bb858d47 [ruby/prism] Match existing Ruby prettyprint
6d8358c083
2023-10-26 15:19:43 -04:00
Kevin Newton
e9aa2398b9 [ruby/prism] Get general prettyprint structure working
7c9cf63d4c
2023-10-26 15:19:35 -04:00
Kevin Newton
5523a23469 [ruby/prism] Attach magic comments to the parse result
c7ef25a79a
2023-10-16 15:40:19 -07:00
Kevin Newton
37d958eaf4 Remove old unescaping code 2023-10-13 15:31:30 -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
Renamed from yarp/extension.c (Browse further)