Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lots and lots of things #2924

Merged
merged 9 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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.rb
/rbi/prism/node.rbi
/rbi/prism/visitor.rbi

Expand Down
25 changes: 25 additions & 0 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
Loading
Loading