Commit graph

11 commits

Author SHA1 Message Date
HASUMI Hitoshi
c4bd6da298 [ruby/prism] Make alloc interface replaceable
- Add `x` prefix to malloc, calloc, realloc, and free
  (eg: malloc -> xmalloc)
- By default, they are replaced with stdlib's functions at build
- You can use custom functions by defining `PRISM_CUSTOM_ALLOCATOR` macro

7a878af619
2024-03-04 16:40:23 +00:00
Kevin Newton
50e999c56d [ruby/prism] Command line options as a bitset
369ffbd57e
2024-02-29 12:05:19 -05:00
Kevin Newton
3ca8b4aee0 [ruby/prism] Support -p, -n, -a, and -l command line options
959eb506ca
2024-02-27 04:22:39 +00:00
Kevin Newton
00bda2aa3b [ruby/prism] Fix up GCC analyzer
2e8bc17528
2024-02-17 21:53:54 +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.

2c86036022
2024-02-13 18:26:28 +00:00
Koichi ITO
246005f5bd [ruby/prism] Fix an error when specifying the parsing version latest
This PR fixes following error when using `version: latest` argument.

```console
$ ruby -rprism -e "p Prism.parse('-> { it }', version: 'latest')"
-e:1:in `parse': invalid version: latest (ArgumentError)

p Prism.parse('-> { it }', version: 'latest')
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        from -e:1:in `<main>'
```

The argument `version: latest` in the added test is commented as potentially being
better replaced with `version: 3.4.0` in the future.

27b5c933cb
2024-02-13 18:15:48 +00:00
Kevin Newton
e9f1324464 Sync to latest prism 2024-02-01 12:52:16 -05: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
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
05f5c545d2
[ruby/prism] Wire up options through the FFI API
f0aa8ad93b
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