Class: Esprima::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/esprima/parser.rb

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



5
6
7
# File 'lib/esprima/parser.rb', line 5

def initialize
  @esprima = Esprima.new_environment
end

Instance Method Details

#parse(code, opts = {}) ⇒ Object



9
10
11
# File 'lib/esprima/parser.rb', line 9

def parse(code, opts = {})
  Esprima::AST.new(to_ruby_hash(@esprima.parse(code, opts)), @esprima)
end

#parse_file(file, opts = {}) ⇒ Object



13
14
15
# File 'lib/esprima/parser.rb', line 13

def parse_file(file, opts = {})
  parse(read_file(file), opts)
end