Skip to content

Commit

Permalink
Merge branch 'main' into gnu-make-implicit-vars
Browse files Browse the repository at this point in the history
  • Loading branch information
ParadoxV5 authored Aug 29, 2024
2 parents 7ce2a66 + 0299f89 commit 469487f
Show file tree
Hide file tree
Showing 1,249 changed files with 18,039 additions and 8,503 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ out.svg
/sig/prism/node.rbs
/sig/prism/visitor.rbs
/sig/prism/_private/dot_visitor.rbs
/rbi/prism/dsl.rbi
/rbi/prism/node.rbi
/rbi/prism/visitor.rbi

Expand Down
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ matrix:
- arch: arm64
- arch: ppc64le
- arch: s390x
allow_failures:
# Allow failures due to the following infra errors.
# The jobs are not starting.
- arch: arm64
# No output has been received in the last 10m0s, this potentially indicates
# a stalled build or something wrong with the build itself.
# https://app.travis-ci.com/github/ruby/prism/builds/271968231
- arch: ppc64le
- arch: s390x
fast_finish: true

before_install:
Expand Down
32 changes: 31 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,35 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a

## [Unreleased]

## [1.0.0] - 2024-08-28

### Added

- Add `Node#breadth_first_search`.
- Add `Node#node_id`.
- Add `ArgumentsNode#contains_splat?`.
- Passing the special value `false` for the `encoding` option tells Prism to ignore magic encoding comments.
- Expose flags on every node type (allows checking static literal and newline).
- Implement mismatched indentation warning.
- Add C API for receiving a callback when parsing shebangs with additional flags.

### Changed

- **BREAKING**: Some fields are renamed that had illogical names. The previous names all now emit deprecation warnings.
- `CaseMatchNode#consequent` was renamed to `CaseMatchNode#else_clause`
- `CaseNode#consequent` was renamed to `CaseNode#else_clause`
- `IfNode#consequent` was renamed to `IfNode#subsequent`
- `RescueNode#consequent` was renamed to `RescueNode#subsequent`
- `UnlessNode#consequent` was renamed to `UnlessNode#else_clause`
- Block exits are now allowed in loop predicates (e.g., `while _ && break do end`).
- Multi-writes are now disallowed when not at the statement level.
- Ensure that range operators are non-associative.
- (JavaScript) Correctly deserialize encoded strings.
- Properly support parsing regular expressions in extended mode.
- Use gmake on FreeBSD.
- Parsing streams now handles NUL bytes in the middle of the stream.
- Properly detect invalid returns.

## [0.30.0] - 2024-06-07

### Added
Expand Down Expand Up @@ -538,7 +567,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a

- 🎉 Initial release! 🎉

[unreleased]: https://github.com/ruby/prism/compare/v0.30.0...HEAD
[unreleased]: https://github.com/ruby/prism/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/ruby/prism/compare/v0.30.0...v1.0.0
[0.30.0]: https://github.com/ruby/prism/compare/v0.29.0...v0.30.0
[0.29.0]: https://github.com/ruby/prism/compare/v0.28.0...v0.29.0
[0.28.0]: https://github.com/ruby/prism/compare/v0.27.0...v0.28.0
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
prism (0.30.0)
prism (1.0.0)

GEM
remote: https://rubygems.org/
Expand All @@ -10,11 +10,11 @@ GEM
benchmark-ips (2.13.0)
ffi (1.17.0)
mini_portile2 (2.8.7)
nokogiri (1.16.5)
nokogiri (1.16.6)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
onigmo (0.1.0)
parser (3.3.2.0)
parser (3.3.3.0)
ast (~> 2.4.1)
racc
power_assert (2.0.3)
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ The repository contains the infrastructure for both a shared library (libprism)
├── rust
│   ├── ruby-prism Rustified crate for the shared library
│   └── ruby-prism-sys FFI binding for Rust
├── sample Sample code that uses the Ruby API for documentation
├── sample
│ └── prism Sample code that uses the Ruby API for documentation purposes
├── sig RBS type signatures for the Ruby library
├── src
│   ├── util various utility files
Expand Down Expand Up @@ -120,6 +121,7 @@ Prism has been integrated into the majority of Ruby runtimes, many libraries, an
### Libraries

* [dispersion](https://github.com/joeldrapper/dispersion)
* [minifyrb](https://github.com/koic/minifyrb)
* [packwerk](https://github.com/Shopify/packwerk/pull/388) (via parser translator)
* [rbi](https://github.com/Shopify/rbi)
* [rails](https://github.com/rails/rails)
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require_relative "templates/template"
desc "Generate all ERB template based files"
task templates: Prism::Template::TEMPLATES

make = RUBY_PLATFORM.include?("openbsd") ? "gmake" : "make"
make = RUBY_PLATFORM.match?(/openbsd|freebsd/) ? "gmake" : "make"
task(make: :templates) { sh(make) }
task(make_no_debug: :templates) { sh("#{make} all-no-debug") }
task(make_minimal: :templates) { sh("#{make} minimal") }
Expand Down
36 changes: 32 additions & 4 deletions bin/prism
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module Prism
when "console" then console
when "dot" then dot(argv)
when "encoding" then encoding(argv)
when "error" then error(argv)
when "lex" then lex(argv)
when "locals" then locals(argv)
when "parse" then parse(argv)
Expand All @@ -27,6 +28,7 @@ module Prism
bin/prism console
bin/prism dot [source]
bin/prism encoding [encoding]
bin/prism error [name] [source]
bin/prism lex [source]
bin/prism locals [source]
bin/prism parse [source]
Expand Down Expand Up @@ -157,6 +159,29 @@ module Prism
unicode_lists(found) if found == Encoding::UTF_8 || found == Encoding::UTF8_MAC
end

# bin/prism error [name] [source]
def error(argv)
name = argv.shift
source, _ = read_source(argv)

result = Prism.parse(source)
raise "Expected #{source.inspect} to have errors" if result.success?

filepath = File.expand_path("../test/prism/errors/#{name}.txt", __dir__)

if File.file?(filepath)
counter = 1

begin
current = "#{File.dirname(filepath)}/#{File.basename(filepath, ".txt")}_#{counter += 1}.txt"
end while File.file?(current)

filepath = current
end

File.write(filepath, result.errors_format)
end

# bin/prism lex [source]
def lex(argv)
source, filepath = read_source(argv)
Expand Down Expand Up @@ -368,14 +393,17 @@ module Prism

# Parse the source code indicated by the command-line arguments.
def parse_source(argv)
command_line = +""
command_line << argv.shift[1] while argv.first&.match?(/^-[alnpx]$/)

case argv.first
when "-e"
argv.shift
Prism.parse(argv.shift, command_line: "e")
command_line << argv.shift[1]
Prism.parse(argv.shift, command_line: command_line)
when nil
Prism.parse_file("test.rb")
Prism.parse_file("test.rb", command_line: command_line)
else
Prism.parse_file(argv.shift)
Prism.parse_file(argv.shift, command_line: command_line)
end
end

Expand Down
Loading

0 comments on commit 469487f

Please sign in to comment.