This module is the entry-point for converting a prism syntax tree into the seattlerb/ruby_parser gem’s syntax tree.
Class Methods
lib/prism/translation/ruby_parser.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/translation/ruby_parser.rb, line 1556
def parse(source, filepath = "(string)")
new.parse(source, filepath)
end
Parse the given source and translate it into the seattlerb/ruby_parser gem’s Sexp format.
lib/prism/translation/ruby_parser.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/translation/ruby_parser.rb, line 1562
def parse_file(filepath)
new.parse_file(filepath)
end
Parse the given file and translate it into the seattlerb/ruby_parser gem’s Sexp format.
Instance Methods
lib/prism/translation/ruby_parser.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/translation/ruby_parser.rb, line 1543
def parse(source, filepath = "(string)")
translate(Prism.parse(source, filepath: filepath, scopes: [[]]), filepath)
end
Parse the given source and translate it into the seattlerb/ruby_parser gem’s Sexp format.
lib/prism/translation/ruby_parser.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/translation/ruby_parser.rb, line 1549
def parse_file(filepath)
translate(Prism.parse_file(filepath, scopes: [[]]), filepath)
end
Parse the given file and translate it into the seattlerb/ruby_parser gem’s Sexp format.
lib/prism/translation/ruby_parser.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/translation/ruby_parser.rb, line 1571
def translate(result, filepath)
if result.failure?
error = result.errors.first
raise ::RubyParser::SyntaxError, "#{filepath}:#{error.location.start_line} :: #{error.message}"
end
result.value.accept(Compiler.new(filepath))
end
Translate the given parse result and filepath into the seattlerb/ruby_parser gem’s Sexp format.