diff options
Diffstat (limited to 'vendor/github.com/hashicorp/hcl/lex.go')
-rw-r--r-- | vendor/github.com/hashicorp/hcl/lex.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/hcl/lex.go b/vendor/github.com/hashicorp/hcl/lex.go new file mode 100644 index 0000000..d9993c2 --- /dev/null +++ b/vendor/github.com/hashicorp/hcl/lex.go | |||
@@ -0,0 +1,38 @@ | |||
1 | package hcl | ||
2 | |||
3 | import ( | ||
4 | "unicode" | ||
5 | "unicode/utf8" | ||
6 | ) | ||
7 | |||
8 | type lexModeValue byte | ||
9 | |||
10 | const ( | ||
11 | lexModeUnknown lexModeValue = iota | ||
12 | lexModeHcl | ||
13 | lexModeJson | ||
14 | ) | ||
15 | |||
16 | // lexMode returns whether we're going to be parsing in JSON | ||
17 | // mode or HCL mode. | ||
18 | func lexMode(v []byte) lexModeValue { | ||
19 | var ( | ||
20 | r rune | ||
21 | w int | ||
22 | offset int | ||
23 | ) | ||
24 | |||
25 | for { | ||
26 | r, w = utf8.DecodeRune(v[offset:]) | ||
27 | offset += w | ||
28 | if unicode.IsSpace(r) { | ||
29 | continue | ||
30 | } | ||
31 | if r == '{' { | ||
32 | return lexModeJson | ||
33 | } | ||
34 | break | ||
35 | } | ||
36 | |||
37 | return lexModeHcl | ||
38 | } | ||