class Prism::Translation::RubyParser
Dieses Modul ist der Einstiegspunkt für die Konvertierung eines Prism-Syntaxbaums in den Syntaxbaum des seattlerb/ruby_parser Gems.
Öffentliche Klassenmethoden
Source
# File lib/prism/translation/ruby_parser.rb, line 1938 def parse(source, filepath = "(string)") new.parse(source, filepath) end
Analysiert den gegebenen Quelltext und übersetzt ihn in das Sexp-Format des seattlerb/ruby_parser Gems.
Source
# File lib/prism/translation/ruby_parser.rb, line 1944 def parse_file(filepath) new.parse_file(filepath) end
Analysiert die gegebene Datei und übersetzt sie in das Sexp-Format des seattlerb/ruby_parser Gems.
Öffentliche Instanzmethoden
Source
# File lib/prism/translation/ruby_parser.rb, line 1917 def parse(source, filepath = "(string)") translate(Prism.parse(source, filepath: filepath, partial_script: true), filepath) end
Analysiert den gegebenen Quelltext und übersetzt ihn in das Sexp-Format des seattlerb/ruby_parser Gems.
Source
# File lib/prism/translation/ruby_parser.rb, line 1923 def parse_file(filepath) translate(Prism.parse_file(filepath, partial_script: true), filepath) end
Analysiert die gegebene Datei und übersetzt sie in das Sexp-Format des seattlerb/ruby_parser Gems.
Source
# File lib/prism/translation/ruby_parser.rb, line 1931 def process(ruby, file = "(string)", timeout = nil) Timeout.timeout(timeout) { parse(ruby, file) } end
Analysiert die gegebene Datei und übersetzt sie in das Sexp-Format des seattlerb/ruby_parser Gems. Diese Methode wird aus API-Kompatibilitätsgründen zu RubyParser bereitgestellt und nimmt ein optionales timeout-Argument entgegen.
Private Instanzmethoden
Source
# File lib/prism/translation/ruby_parser.rb, line 1953 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
Übersetzt das gegebene Parse-Ergebnis und den Dateipfad in das Sexp-Format des seattlerb/ruby_parser Gems.