mirror of
https://github.com/sorenisanerd/gotty.git
synced 2024-11-09 23:34:26 +00:00
32 lines
417 B
Go
32 lines
417 B
Go
package hcl
|
|
|
|
import (
|
|
"unicode"
|
|
)
|
|
|
|
type lexModeValue byte
|
|
|
|
const (
|
|
lexModeUnknown lexModeValue = iota
|
|
lexModeHcl
|
|
lexModeJson
|
|
)
|
|
|
|
// lexMode returns whether we're going to be parsing in JSON
|
|
// mode or HCL mode.
|
|
func lexMode(v string) lexModeValue {
|
|
for _, r := range v {
|
|
if unicode.IsSpace(r) {
|
|
continue
|
|
}
|
|
|
|
if r == '{' {
|
|
return lexModeJson
|
|
} else {
|
|
return lexModeHcl
|
|
}
|
|
}
|
|
|
|
return lexModeHcl
|
|
}
|