Class: Esprima::Parser
- Inherits:
-
Object
- Object
- Esprima::Parser
- Defined in:
- lib/esprima/parser.rb
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #parse(code) ⇒ Object
- #parse_file(file) ⇒ Object
Constructor Details
#initialize ⇒ Parser
5 6 7 |
# File 'lib/esprima/parser.rb', line 5 def initialize @esprima = Esprima.new_environment end |
Instance Method Details
#parse(code) ⇒ Object
9 10 11 |
# File 'lib/esprima/parser.rb', line 9 def parse(code) Esprima::AST.new(to_ruby_hash(@esprima.parse(code)), @esprima) end |
#parse_file(file) ⇒ Object
13 14 15 |
# File 'lib/esprima/parser.rb', line 13 def parse_file(file) parse(read_file(file)) end |