Commit graph

68 commits

Author SHA1 Message Date
Kevin Newton
75640037bf [ruby/prism] Fix up multi target parsing
80cd335222
2024-10-04 16:22:21 +00:00
Kevin Newton
f8568fbd7f [ruby/prism] Pop lex mode for heredocs in the lexer, not the parser
5dd36b979e
2024-10-03 17:30:20 +00:00
Kevin Newton
f515a1ab4b [ruby/prism] Introduce partial_script option
b28877fa4f
2024-09-20 15:42:12 +00:00
Kevin Newton
2effa98b6f [ruby/prism] Implement mismatched indentation warning
5d5bf92be8
2024-07-22 18:57:10 +00:00
Kevin Newton
ac093f5a06 [PRISM] Fix up shareable constant casting 2024-07-11 14:25:54 -04:00
Kevin Newton
2bf9ae3fa1 [ruby/prism] Add node ids to nodes
bf16ade7f9
2024-07-11 14:25:54 -04:00
Kevin Newton
d827d32527 [ruby/prism] Provide ability to lock encoding while parsing
f7faedfb3f
2024-06-10 17:21:32 -04:00
Kevin Newton
21e06e57af [ruby/prism] Allow block exits in loop predicates
f09db18e46
2024-06-10 13:42:40 +00:00
Kevin Newton
e575954887 [ruby/prism] Fix support for 'it' implicit local variable
53bbcfe513
2024-05-22 16:34:04 -04:00
Kevin Newton
ff43b4a28b [ruby/prism] Add error for numbered parameter used in inner block
c386ba6d48
2024-05-21 15:46:45 +00:00
Kevin Newton
4c431744b7 [ruby/prism] Warn for nested hashes as well
76e802f59e
2024-04-24 19:39:42 +00:00
Kevin Newton
f72436f835 [ruby/prism] Inline pm_state_stack 2024-04-17 10:36:52 -04:00
Kevin Newton
3b59addaf1 [ruby/prism] Provide documentation for the new local tables
7a47a1351f
2024-04-05 19:24:01 +00:00
Kevin Newton
dcec1e0dc6 [ruby/prism] Replace old circular parameter definition detection
c739f8e194
2024-04-05 19:24:00 +00:00
Kevin Newton
b5b4628991 [ruby/prism] Warn on unused local variables
de111935fb
2024-04-05 19:23:59 +00:00
Kevin Newton
358aeb103b [ruby/prism] Switch locals to use a hash
f38946021e
2024-04-05 19:23:57 +00:00
Kevin Newton
6bbb3e31fb [ruby/prism] Allow retry in rescue modifier
debe19459a
2024-04-03 17:34:12 -04:00
Kevin Newton
e48fd40974 [ruby/prism] No invalid block exits in eval
85e045ce40
2024-04-03 17:34:12 -04:00
Kevin Newton
bddd004ce9 [ruby/prism] Further delineate block types
750116e5dc
2024-04-03 17:34:12 -04:00
Kevin Newton
e19fccbfdb [ruby/prism] Delineate rescue/else/ensure for more accurate exits
92868fad78
2024-04-03 17:34:12 -04:00
Kevin Newton
be48b733b6 [ruby/prism] Pass block exits up the tree
168f72b9fe
2024-04-03 17:34:12 -04:00
Kevin Newton
198d197aeb [ruby/prism] Allow block exits in defined? and fix modifier while/until
2752f0b8df
2024-04-03 17:34:12 -04:00
Kevin Newton
a08954569f
[ruby/prism] Fix up minimal build setting
98c85c4acb
2024-03-25 11:54:20 -04:00
Kevin Newton
53cc272387 [ruby/prism] Handle CLRF in regexp
b96bada9ae
2024-03-25 11:52:13 -04:00
Kevin Newton
c45ad17fa1 [ruby/prism] Shareable constant nodes
473cfed6d0
2024-03-15 12:31:26 +00:00
Jean Boussier
53a77d9b90 [ruby/prism] Change frozen_string_literal to be a tri-state
An explicit `false` is not equivalent to the comment being missing,
because the default can be switched with a runtime flag:

```bash
$ ruby --enable-frozen-string-literal -e 'p "foo".frozen?'
true
```

4660f58775
2024-03-13 16:03:24 +00:00
Kevin Newton
35c20cda70 [ruby/prism] Simplify the regular expression ASCII-only check
b7851f4c2d
2024-03-08 19:18:42 +00:00
Kevin Menard
82fb6a90d5 [ruby/prism] Track both the unescaped bytes and source string for a regular expression so we can accurately set its encoding flags.
dc6dd3a926
2024-03-08 18:48:53 +00:00
Kevin Newton
76e11595e2 [ruby/prism] Fix up tilde heredoc line continuations
15e74b2f65
2024-03-07 20:25:24 +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
90c5393f9f [ruby/prism] Support ItParametersNode
So that compilers know they need to add to add an anonymous
variable to the local table.

7f1aadd057
2024-02-21 17:55:11 -05:00
Kevin Newton
8e4d1ff5da [ruby/prism] Disallow numbered parameters within given scopes
a218a0f265
2024-02-16 17:50:32 +00:00
Kevin Newton
332d2c92d8 [PRISM] Emit parse warnings 2024-02-01 15:52:19 -05:00
Kevin Newton
e9f1324464 Sync to latest prism 2024-02-01 12:52:16 -05:00
Aaron Patterson
8e708e4a07 Update forwarding locals for prism 2024-01-30 13:19:06 -05:00
Kevin Newton
ba06a8259a [ruby/prism] Better error messages for unexpected tokens in prefix
a35b8e45ee
2024-01-30 16:10:08 +00:00
Kevin Newton
80da9b1547 [ruby/prism] Clarify __END__ comment
3e36d5eabc
2024-01-09 19:02: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
Hiroshi SHIBATA
fa251d60aa Revert "Revert all of commits after Prism 0.19.0 release"
This reverts commit d242e8416e.
2023-12-25 21:12:49 +09:00
Hiroshi SHIBATA
d242e8416e
Revert all of commits after Prism 0.19.0 release
We should bundle released version of Prism for Ruby 3.3.0
2023-12-16 11:08:51 +08:00
Ufuk Kayserilioglu
0a31cb1a37 [ruby/prism] Finish keyword hash node flag refactor by renaming flag
7f812389f8
2023-12-15 18:45:36 +00:00
Ufuk Kayserilioglu
01f21d5729 [ruby/prism] Fix the implementation of the flag on keyword hash nodes
The previous implementation was incorrect since it was just checking for all keys in assoc nodes to be static literals but the actual check is that all keys in assoc nodes must be symbol nodes.

This commit fixes that implementation, and, also, aliases the flag to `PM_KEYWORD_HASH_NODE_FLAGS_SYMBOL_KEYS` so that ruby/ruby can start using the new flag name.

I intend to later change the real flag name to `PM_KEYWORD_HASH_NODE_FLAGS_SYMBOL_KEYS` and remove the alias.

f5099c79ce
2023-12-14 18:05:54 +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
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.

2d87303903
2023-12-01 12:03:09 -05:00
Matt Valentine-House
ce5f5ca1d6 [PRISM] Remove transparent scope nodes 2023-12-01 15:04:13 +00:00
Kevin Newton
ea409958b3 [ruby/prism] Remove ability to decode other encodings
98e218d989
2023-11-30 21:37:56 -05:00
Kevin Newton
abb1fe2868 [PRISM] Consolidate prism encoding files 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