diff options
author | Jake Champlin <jake.champlin.27@gmail.com> | 2017-06-06 12:40:07 -0400 |
---|---|---|
committer | Jake Champlin <jake.champlin.27@gmail.com> | 2017-06-06 12:40:07 -0400 |
commit | bae9f6d2fd5eb5bc80929bd393932b23f14d7c93 (patch) | |
tree | ca9ab12a7d78b1fc27a8f734729081357ce6d252 /vendor/github.com/hashicorp/hcl/parse.go | |
parent | 254c495b6bebab3fb72a243c4bce858d79e6ee99 (diff) | |
download | terraform-provider-statuscake-bae9f6d2fd5eb5bc80929bd393932b23f14d7c93.tar.gz terraform-provider-statuscake-bae9f6d2fd5eb5bc80929bd393932b23f14d7c93.tar.zst terraform-provider-statuscake-bae9f6d2fd5eb5bc80929bd393932b23f14d7c93.zip |
Initial transfer of provider code
Diffstat (limited to 'vendor/github.com/hashicorp/hcl/parse.go')
-rw-r--r-- | vendor/github.com/hashicorp/hcl/parse.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/hcl/parse.go b/vendor/github.com/hashicorp/hcl/parse.go new file mode 100644 index 0000000..1fca53c --- /dev/null +++ b/vendor/github.com/hashicorp/hcl/parse.go | |||
@@ -0,0 +1,39 @@ | |||
1 | package hcl | ||
2 | |||
3 | import ( | ||
4 | "fmt" | ||
5 | |||
6 | "github.com/hashicorp/hcl/hcl/ast" | ||
7 | hclParser "github.com/hashicorp/hcl/hcl/parser" | ||
8 | jsonParser "github.com/hashicorp/hcl/json/parser" | ||
9 | ) | ||
10 | |||
11 | // ParseBytes accepts as input byte slice and returns ast tree. | ||
12 | // | ||
13 | // Input can be either JSON or HCL | ||
14 | func ParseBytes(in []byte) (*ast.File, error) { | ||
15 | return parse(in) | ||
16 | } | ||
17 | |||
18 | // ParseString accepts input as a string and returns ast tree. | ||
19 | func ParseString(input string) (*ast.File, error) { | ||
20 | return parse([]byte(input)) | ||
21 | } | ||
22 | |||
23 | func parse(in []byte) (*ast.File, error) { | ||
24 | switch lexMode(in) { | ||
25 | case lexModeHcl: | ||
26 | return hclParser.Parse(in) | ||
27 | case lexModeJson: | ||
28 | return jsonParser.Parse(in) | ||
29 | } | ||
30 | |||
31 | return nil, fmt.Errorf("unknown config format") | ||
32 | } | ||
33 | |||
34 | // Parse parses the given input and returns the root object. | ||
35 | // | ||
36 | // The input format can be either HCL or JSON. | ||
37 | func Parse(input string) (*ast.File, error) { | ||
38 | return parse([]byte(input)) | ||
39 | } | ||