class Prism::Translation::RubyParser
seattlerb/ruby_parser gem’s syntax tree.
This module is the entry-point for converting a prism syntax tree into the
def parse(source, filepath = "(string)")
Parse the given source and translate it into the seattlerb/ruby_parser
def parse(source, filepath = "(string)") translate(Prism.parse(source, filepath: filepath, partial_script: true), filepath) end
def parse(source, filepath = "(string)")
Parse the given source and translate it into the seattlerb/ruby_parser
def parse(source, filepath = "(string)") new.parse(source, filepath) end
def parse_file(filepath)
Parse the given file and translate it into the seattlerb/ruby_parser
def parse_file(filepath) translate(Prism.parse_file(filepath, partial_script: true), filepath) end
def parse_file(filepath)
Parse the given file and translate it into the seattlerb/ruby_parser
def parse_file(filepath) new.parse_file(filepath) end
def process(ruby, file = "(string)", timeout = nil)
provided for API compatibility to RubyParser and takes an
seattlerb/ruby_parser gem's Sexp format. This method is
Parse the give file and translate it into the
def process(ruby, file = "(string)", timeout = nil) Timeout.timeout(timeout) { parse(ruby, file) } end
def translate(result, filepath)
Translate the given parse result and filepath into the
def translate(result, filepath) if result.failure? error = result.errors.first raise ::RubyParser::SyntaxError, "#{filepath}:#{error.location.start_line} :: #{error.message}" end result.attach_comments! result.value.accept(Compiler.new(filepath)) end