| Age | Commit message (Collapse) | Author |
|
|
|
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.
[Backport #21188]
|
|
default gem
* This is notably necessary on TruffleRuby, which is updating to Ruby 3.3 which introduces Prism as a default gem.
* Using the existing path is not an option as it would end up in truffleruby/lib/build/libprism.so and
"truffleruby/lib/include/#{header}" which are not good places for such files.
https://github.com/ruby/prism/commit/5d16473e69
|
|
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/098f1c4607
|
|
https://github.com/ruby/prism/commit/a4fcd5339a
|
|
https://github.com/ruby/prism/commit/b28877fa4f
|
|
https://github.com/ruby/prism/commit/0b527ca93f
|
|
https://github.com/ruby/prism/commit/d68ea29d04
Notes:
Merged: https://github.com/ruby/ruby/pull/11497
|
|
https://github.com/ruby/prism/commit/f7faedfb3f
|
|
https://github.com/ruby/prism/commit/6f886be0a4
|
|
https://github.com/ruby/prism/commit/4d8929ff6a
|
|
Follow up https://github.com/ruby/prism/pull/2760.
This PR updates the `Translation::Parser` to use version 3.3.1 when the version 3.3 is specified.
The Parser gem is structured to support the latest patch versions, hence this aligns with Parser-compatible versioning.
As noted in https://github.com/ruby/prism/pull/2760, the behavior remains unchanged with this switch from 3.3.0 to 3.3.1.
https://github.com/ruby/prism/commit/efde09d318
|
|
https://github.com/ruby/prism/commit/40993166a8
|
|
https://github.com/ruby/prism/commit/17194e096d
|
|
https://github.com/ruby/prism/commit/f3f9950a74
|
|
https://github.com/ruby/prism/commit/2068e3c30a
|
|
https://github.com/ruby/prism/commit/665f533373
|
|
https://github.com/ruby/prism/commit/efdc2b7222
|
|
https://github.com/ruby/prism/commit/369ffbd57e
|
|
https://github.com/ruby/prism/commit/4ef4032774
|
|
https://github.com/ruby/prism/commit/959eb506ca
|
|
* For Prism.parse_file the file contents would be read as native, then
converted to a Ruby String, then converted to a native String for
pm_serialize_parse().
* Refactor the logic to always use a pm_string for the source code and
pass that to other native functions.
https://github.com/ruby/prism/commit/9002b3c47d
|
|
This is effectively an alias for "latest" right now. In the future
it will change to be its own enum value.
https://github.com/ruby/prism/commit/2c86036022
|
|
This PR implements proper file parsing error handling. Previously
`file_options` would call `pm_string_mapped_init` which would print an
error from `perror`. However this wouldn't raise a proper Ruby error so
it was just a string output. I've done the following:
- Raise an error from `rb_syserr_fail` with the filepath in
`file_options`.
- No longer return `Qnil` if `file_options` returns false (because now
it will raise)
- Update `file_options` to return `static void` instead of `static
bool`.
- Update `file_options` and `profile_file` to check the type so when
passing `nil` we see a `TypeError`.
- Delete `perror` from `pm_string_mapped_init`
- Update `FFI` backend to raise appropriate errors when calling
`pm_string_mapped_init`.
- Add tests for `dump_file`, `lex_file`, `parse_file`,
`parse_file_comments`, `parse_lex_file`, and `parse_file_success?`
when a file doesn't exist and for `nil`.
- Updates the `bin/parse` script to no longer raise it's own
`ArgumentError` now that we raise a proper error.
Fixes: ruby/prism#2207
https://github.com/ruby/prism/commit/b2f7494ff5
|
|
|
|
https://github.com/ruby/prism/commit/d7fe7c7ae7
|
|
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
|
|
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.
https://github.com/ruby/prism/commit/7014740118
|
|
https://github.com/ruby/prism/commit/42b60b6e95
|
|
(https://github.com/ruby/prism/pull/1899)
https://github.com/ruby/prism/commit/1b41c2d56c
|
|
(https://github.com/ruby/prism/pull/1809)
https://github.com/ruby/prism/commit/d493ccd093
|
|
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.
https://github.com/ruby/prism/commit/8600b06811
|
|
https://github.com/ruby/prism/commit/fbb30216ca
|
|
https://github.com/ruby/prism/commit/13fa262669
|
|
https://github.com/ruby/prism/commit/5a2252e3ac
|
|
https://github.com/ruby/prism/commit/f0aa8ad93b
|
|
https://github.com/ruby/prism/commit/ca9a660f52
|
|
https://github.com/ruby/prism/commit/bd4d248fd6
|
|
https://github.com/ruby/prism/commit/5b72f84480
|
|
https://github.com/ruby/prism/commit/c7ef25a79a
|
|
Only remove const prefix from non-pointer types.
https://github.com/ruby/prism/commit/97c9ffeb42
|
|
|
|
|