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

66 Коммитов

Автор SHA1 Сообщение Дата
Kevin Newton f515a1ab4b [ruby/prism] Introduce partial_script option
https://github.com/ruby/prism/commit/b28877fa4f
2024-09-20 15:42:12 +00:00
Kevin Newton 2effa98b6f [ruby/prism] Implement mismatched indentation warning
https://github.com/ruby/prism/commit/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
https://github.com/ruby/prism/commit/bf16ade7f9
2024-07-11 14:25:54 -04:00
Kevin Newton d827d32527 [ruby/prism] Provide ability to lock encoding while parsing
https://github.com/ruby/prism/commit/f7faedfb3f
2024-06-10 17:21:32 -04:00
Kevin Newton 21e06e57af [ruby/prism] Allow block exits in loop predicates
https://github.com/ruby/prism/commit/f09db18e46
2024-06-10 13:42:40 +00:00
Kevin Newton e575954887 [ruby/prism] Fix support for 'it' implicit local variable
https://github.com/ruby/prism/commit/53bbcfe513
2024-05-22 16:34:04 -04:00
Kevin Newton ff43b4a28b [ruby/prism] Add error for numbered parameter used in inner block
https://github.com/ruby/prism/commit/c386ba6d48
2024-05-21 15:46:45 +00:00
Kevin Newton 4c431744b7 [ruby/prism] Warn for nested hashes as well
https://github.com/ruby/prism/commit/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
https://github.com/ruby/prism/commit/7a47a1351f
2024-04-05 19:24:01 +00:00
Kevin Newton dcec1e0dc6 [ruby/prism] Replace old circular parameter definition detection
https://github.com/ruby/prism/commit/c739f8e194
2024-04-05 19:24:00 +00:00
Kevin Newton b5b4628991 [ruby/prism] Warn on unused local variables
https://github.com/ruby/prism/commit/de111935fb
2024-04-05 19:23:59 +00:00
Kevin Newton 358aeb103b [ruby/prism] Switch locals to use a hash
https://github.com/ruby/prism/commit/f38946021e
2024-04-05 19:23:57 +00:00
Kevin Newton 6bbb3e31fb [ruby/prism] Allow retry in rescue modifier
https://github.com/ruby/prism/commit/debe19459a
2024-04-03 17:34:12 -04:00
Kevin Newton e48fd40974 [ruby/prism] No invalid block exits in eval
https://github.com/ruby/prism/commit/85e045ce40
2024-04-03 17:34:12 -04:00
Kevin Newton bddd004ce9 [ruby/prism] Further delineate block types
https://github.com/ruby/prism/commit/750116e5dc
2024-04-03 17:34:12 -04:00
Kevin Newton e19fccbfdb [ruby/prism] Delineate rescue/else/ensure for more accurate exits
https://github.com/ruby/prism/commit/92868fad78
2024-04-03 17:34:12 -04:00
Kevin Newton be48b733b6 [ruby/prism] Pass block exits up the tree
https://github.com/ruby/prism/commit/168f72b9fe
2024-04-03 17:34:12 -04:00
Kevin Newton 198d197aeb [ruby/prism] Allow block exits in defined? and fix modifier while/until
https://github.com/ruby/prism/commit/2752f0b8df
2024-04-03 17:34:12 -04:00
Kevin Newton a08954569f
[ruby/prism] Fix up minimal build setting
https://github.com/ruby/prism/commit/98c85c4acb
2024-03-25 11:54:20 -04:00
Kevin Newton 53cc272387 [ruby/prism] Handle CLRF in regexp
https://github.com/ruby/prism/commit/b96bada9ae
2024-03-25 11:52:13 -04:00
Kevin Newton c45ad17fa1 [ruby/prism] Shareable constant nodes
https://github.com/ruby/prism/commit/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
```

https://github.com/ruby/prism/commit/4660f58775
2024-03-13 16:03:24 +00:00
Kevin Newton 35c20cda70 [ruby/prism] Simplify the regular expression ASCII-only check
https://github.com/ruby/prism/commit/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.
https://github.com/ruby/prism/commit/dc6dd3a926
2024-03-08 18:48:53 +00:00
Kevin Newton 76e11595e2 [ruby/prism] Fix up tilde heredoc line continuations
https://github.com/ruby/prism/commit/15e74b2f65
2024-03-07 20:25:24 +00:00
Kevin Newton 50e999c56d [ruby/prism] Command line options as a bitset
https://github.com/ruby/prism/commit/369ffbd57e
2024-02-29 12:05:19 -05: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 90c5393f9f [ruby/prism] Support ItParametersNode
So that compilers know they need to add to add an anonymous
variable to the local table.

https://github.com/ruby/prism/commit/7f1aadd057
2024-02-21 17:55:11 -05:00
Kevin Newton 8e4d1ff5da [ruby/prism] Disallow numbered parameters within given scopes
https://github.com/ruby/prism/commit/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
https://github.com/ruby/prism/commit/a35b8e45ee
2024-01-30 16:10:08 +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 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
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
https://github.com/ruby/prism/commit/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.

https://github.com/ruby/prism/commit/f5099c79ce
2023-12-14 18:05:54 +00:00
Kevin Newton 82f18baa21 [ruby/prism] Provide flags for changing encodings
https://github.com/ruby/prism/commit/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
https://github.com/ruby/prism/commit/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.

https://github.com/ruby/prism/commit/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
https://github.com/ruby/prism/commit/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
```

https://github.com/ruby/prism/commit/0d14ed1452
2023-11-29 13:56:19 +00:00
TSUYUSATO Kitsune a908cef53f [ruby/prism] Reject class/module defs in method params/rescue/ensure/else
Fix https://github.com/ruby/prism/pull/1936

https://github.com/ruby/prism/commit/232e77a003
2023-11-29 02:03:06 +00:00
Jemma Issroff 04cbcd37b1 [ruby/prism] Add numbered_parameters field to BlockNode and LambdaNode
We are aware at parse time how many numbered parameters we have
on a BlockNode or LambdaNode, but prior to this commit, did not
store that information anywhere in its own right.

The numbered parameters were stored as locals, but this does not
distinguish them from other locals that have been set, for example
in `a { b = 1; _1 }` there is nothing on the AST that distinguishes
b from _1.

Consumers such as the compiler need to know information about how
many numbered parameters exist to set up their own tables around
parameters. Since we have this information at parse time, we should
compute it here, instead of deferring the work later on.

https://github.com/ruby/prism/commit/bf4a1e124d
2023-11-28 21:08:46 +00:00