Class: HCL::Parser

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

Instance Method Summary collapse

Constructor Details

#initialize(src) ⇒ Parser

Returns a new instance of Parser.



2
3
4
5
# File 'lib/hcl/parser.rb', line 2

def initialize(src)
  @src = src
  @parslet = HCL::Parslet.new
end

Instance Method Details

#parseObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/hcl/parser.rb', line 7

def parse
  ast = begin
   @parslet.parse(@src)
 rescue Parslet::ParseFailed => error
   puts error.parse_failure_cause.ascii_tree
   raise
 end

  HCL::Decoder.new.decode(ast)
end