Class: Prism::Translation::RubyParser

Inherits:
Object
  • Object
show all
Defined in:
lib/prism/translation/ruby_parser.rb

Overview

This module is the entry-point for converting a prism syntax tree into the seattlerb/ruby_parser gem’s syntax tree.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(source, filepath = "(string)") ⇒ Object

Parse the given source and translate it into the seattlerb/ruby_parser gem’s Sexp format.



1904
1905
1906
# File 'lib/prism/translation/ruby_parser.rb', line 1904

def parse(source, filepath = "(string)")
  new.parse(source, filepath)
end

.parse_file(filepath) ⇒ Object

Parse the given file and translate it into the seattlerb/ruby_parser gem’s Sexp format.



1910
1911
1912
# File 'lib/prism/translation/ruby_parser.rb', line 1910

def parse_file(filepath)
  new.parse_file(filepath)
end

Instance Method Details

#parse(source, filepath = "(string)") ⇒ Object

Parse the given source and translate it into the seattlerb/ruby_parser gem’s Sexp format.



1891
1892
1893
# File 'lib/prism/translation/ruby_parser.rb', line 1891

def parse(source, filepath = "(string)")
  translate(Prism.parse(source, filepath: filepath, partial_script: true), filepath)
end

#parse_file(filepath) ⇒ Object

Parse the given file and translate it into the seattlerb/ruby_parser gem’s Sexp format.



1897
1898
1899
# File 'lib/prism/translation/ruby_parser.rb', line 1897

def parse_file(filepath)
  translate(Prism.parse_file(filepath, partial_script: true), filepath)
end