hcl/lex.go

32 lines
417 B
Go
Raw Normal View History

2014-07-31 20:56:51 +00:00
package hcl
import (
"unicode"
)
2014-08-01 19:54:53 +00:00
type lexModeValue byte
2014-07-31 20:56:51 +00:00
2014-08-01 19:54:53 +00:00
const (
lexModeUnknown lexModeValue = iota
lexModeHcl
lexModeJson
)
2014-07-31 20:56:51 +00:00
2014-08-01 19:54:53 +00:00
// 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) {
2014-07-31 20:56:51 +00:00
continue
}
2014-08-01 19:54:53 +00:00
if r == '{' {
return lexModeJson
} else {
return lexModeHcl
2014-07-31 20:56:51 +00:00
}
}
2014-09-15 16:40:47 +00:00
return lexModeHcl
2014-07-31 20:56:51 +00:00
}