2014-07-31 13:56:51 -07:00
|
|
|
package hcl
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unicode"
|
|
|
|
)
|
|
|
|
|
2014-08-01 12:54:53 -07:00
|
|
|
type lexModeValue byte
|
2014-07-31 13:56:51 -07:00
|
|
|
|
2014-08-01 12:54:53 -07:00
|
|
|
const (
|
|
|
|
lexModeUnknown lexModeValue = iota
|
|
|
|
lexModeHcl
|
|
|
|
lexModeJson
|
|
|
|
)
|
2014-07-31 13:56:51 -07:00
|
|
|
|
2014-08-01 12:54:53 -07: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 13:56:51 -07:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2014-08-01 12:54:53 -07:00
|
|
|
if r == '{' {
|
|
|
|
return lexModeJson
|
|
|
|
} else {
|
|
|
|
return lexModeHcl
|
2014-07-31 13:56:51 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-01 12:54:53 -07:00
|
|
|
return lexModeUnknown
|
2014-07-31 13:56:51 -07:00
|
|
|
}
|