This commit is contained in:
Mitchell Hashimoto 2014-08-02 11:44:14 -07:00
parent d5f339015f
commit 3a02b49a51
1 changed files with 23 additions and 0 deletions

23
parse.go Normal file
View File

@ -0,0 +1,23 @@
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")
}