| Age | Commit message (Collapse) | Author |
|
In the C API, we want to use slices instead of locations in the
AST. In this case a "slice" is effectively the same thing as the
location, expect it is represented using a 32-bit offset and a
32-bit length. This will cut down on half of the space of all of
the locations in the AST.
Note that from the Ruby/Java/JavaScript side, this is effectively
an invisible change. This only impacts the C/Rust side.
|
|
https://github.com/ruby/prism/commit/ebf4425d49
|
|
The docs currently say to use `Prism.parse(foo, version: RUBY_VERSION)` for this.
By specifying "current" instead, we can have prism raise a more specifc error.
Note: Does not use `ruby_version` from `ruby/version.h` because writing a test for that is not really possible.
`RUBY_VERSION` is nicely stubbable for both the c-ext and FFI backend.
https://github.com/ruby/prism/commit/9c5cd205cf
|
|
The purpose of this commit is to fix Bug #21188. We need to detect when
stdin has run in to an EOF case. Unfortunately we can't _call_ the eof
function on IO because it will block.
Here is a short script to demonstrate the issue:
```ruby
x = STDIN.gets
puts x
puts x.eof?
```
If you run the script, then type some characters (but _NOT_ a newline),
then hit Ctrl-D twice, it will print the input string. Unfortunately,
calling `eof?` will try to read from STDIN again causing us to need a
3rd Ctrl-D to exit the program.
Before introducing the EOF callback to Prism, the input loop looked
kind of like this:
```ruby
loop do
str = STDIN.gets
process(str)
if str.nil?
p :DONE
end
end
```
Which required 3 Ctrl-D to exit. If we naively changed it to something
like this:
```ruby
loop do
str = STDIN.gets
process(str)
if STDIN.eof?
p :DONE
end
end
```
It would still require 3 Ctrl-D because `eof?` would block. In this
patch, we're wrapping the IO object, checking the buffer for a newline
and length, and then using that to simulate a non-blocking eof? method.
This commit wraps STDIN and emulates a non-blocking `eof` function.
[Bug #21188]
|
|
https://github.com/ruby/prism/commit/c02429765b
|
|
https://github.com/ruby/prism/commit/56eaf53732
|
|
https://github.com/ruby/prism/commit/10e5431b38
|
|
Closes https://github.com/ruby/prism/pull/3422
https://github.com/ruby/prism/commit/b488a84253
|
|
When parent scopes around an eval are forwarding parameters (like
*, **, &, or ...) we need to know that information when we are in
the parser. As such, we need to support passing that information
into the scopes option. In order to do this, unfortunately we need
a bunch of changes.
The scopes option was previously an array of array of strings.
These corresponded to the names of the locals in the parent scopes.
We still support this, but now additionally support passing in a
Prism::Scope instance at each index in the array. This Prism::Scope
class holds both the names of the locals as well as an array of
forwarding parameter names (symbols corresponding to the forwarding
parameters). There is convenience function on the Prism module that
creates a Prism::Scope object using Prism.scope.
In JavaScript, we now additionally support an object much the same
as the Ruby side. In Java, we now have a ParsingOptions.Scope class
that holds that information. In the dump APIs, these objects in all
3 languages will add an additional byte for the forwarding flags in
the middle of the scopes serialization.
All of this is in service of properly parsing the following code:
```ruby
def foo(*) = eval("bar(*)")
```
https://github.com/ruby/prism/commit/21abb6b7c4
|
|
https://github.com/ruby/prism/commit/8ab2532f09
|
|
To make it so that you can pass `freeze: true` to Prism parse
methods and get back a deeply-frozen AST that is Ractor-
shareable.
https://github.com/ruby/prism/commit/8e6a93b2d2
|
|
https://github.com/ruby/prism/commit/0635814327
|
|
Introduce StringQuery to provide methods to access some metadata
about the Ruby lexer.
https://github.com/ruby/prism/commit/d3f55b67b9
|
|
https://github.com/ruby/prism/commit/a4fcd5339a
|
|
* Otherwise it is invalid e.g. to call strlen() to the result,
or to assume the argument was a string.
* All callers are already checking for nil before.
https://github.com/ruby/prism/commit/8197be883e
|
|
https://github.com/ruby/prism/commit/b28877fa4f
|
|
https://github.com/ruby/prism/commit/0b527ca93f
|
|
Fixes [Bug #20730]
Notes:
Merged: https://github.com/ruby/ruby/pull/11617
|
|
https://github.com/ruby/prism/commit/d68ea29d04
Notes:
Merged: https://github.com/ruby/ruby/pull/11497
|
|
https://github.com/ruby/prism/commit/487f0ffe78
|
|
… by allocating them with the correct capacity.
|
|
https://github.com/ruby/prism/commit/084baca463
|
|
`Prism.lex` and `Prism.lex_file` return `ParseLexResult` instead of `Array`.
`Prism::parse_lex` and `Prism::parse_lex_file` return `ParseLexResult` instead of `ParseResult`.
This PR updates the documentation to reflect these return values.
https://github.com/ruby/prism/commit/ee331941c0
|
|
https://github.com/ruby/prism/commit/4a41d298c8
|
|
https://github.com/ruby/prism/commit/4601d3adfd
|
|
https://github.com/ruby/prism/commit/f7faedfb3f
|
|
|
|
https://github.com/ruby/prism/commit/b850794db9
|
|
https://github.com/ruby/prism/commit/53b2866487
|
|
https://github.com/ruby/prism/commit/5050dfbe70
|
|
https://github.com/ruby/prism/commit/75fabf7081
|
|
https://github.com/ruby/prism/commit/283938ed1f
|
|
https://github.com/ruby/prism/commit/14e397598b
|
|
https://github.com/ruby/prism/commit/486c71c426
|
|
https://github.com/ruby/prism/commit/40993166a8
|
|
https://github.com/ruby/prism/commit/b3e104e8a2
|
|
https://github.com/ruby/prism/commit/17194e096d
|
|
https://github.com/ruby/prism/commit/f3f9950a74
|
|
https://github.com/ruby/prism/commit/f540e830b5
|
|
https://github.com/ruby/prism/commit/2068e3c30a
|
|
https://github.com/ruby/prism/commit/af0204a8ab
|
|
After finding the "if if" typo, some additional typos identified by running `codespell` are also being corrected:
https://github.com/codespell-project/codespell
https://github.com/ruby/prism/commit/e6a34cfeeb
|
|
https://github.com/ruby/prism/commit/98c85c4acb
|
|
https://github.com/ruby/prism/commit/592128de4d
|
|
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
|
|
https://github.com/ruby/prism/commit/4913d112da
|
|
https://github.com/ruby/prism/commit/665f533373
|
|
https://github.com/ruby/prism/commit/a2594a23c1
|
|
https://github.com/ruby/prism/commit/588acf823f
|
|
https://github.com/ruby/prism/commit/f0a2ce1c0e
|