hcl/parse.go
Mitchell Hashimoto 3a02b49a51 parse
2014-08-02 11:44:14 -07:00

24 lines
467 B
Go

package hcl
import (
"fmt"
"github.com/hashicorp/hcl/ast"
"github.com/hashicorp/hcl/hcl"
"github.com/hashicorp/hcl/json"
)
// Parse parses the given input and returns the root of the AST.
//
// The input format can be either HCL or JSON.
func Parse(input string) (*ast.ObjectNode, error) {
switch lexMode(input) {
case lexModeHcl:
return hcl.Parse(input)
case lexModeJson:
return json.Parse(input)
}
return nil, fmt.Errorf("unknown config format")
}