6c4344623b
The main HCL package is more visible this way, and so it's easier than having to pick it out from dozens of other package directories.
22 lines
521 B
Go
22 lines
521 B
Go
package hclsyntax
|
|
|
|
import (
|
|
"bytes"
|
|
)
|
|
|
|
type Keyword []byte
|
|
|
|
var forKeyword = Keyword([]byte{'f', 'o', 'r'})
|
|
var inKeyword = Keyword([]byte{'i', 'n'})
|
|
var ifKeyword = Keyword([]byte{'i', 'f'})
|
|
var elseKeyword = Keyword([]byte{'e', 'l', 's', 'e'})
|
|
var endifKeyword = Keyword([]byte{'e', 'n', 'd', 'i', 'f'})
|
|
var endforKeyword = Keyword([]byte{'e', 'n', 'd', 'f', 'o', 'r'})
|
|
|
|
func (kw Keyword) TokenMatches(token Token) bool {
|
|
if token.Type != TokenIdent {
|
|
return false
|
|
}
|
|
return bytes.Equal([]byte(kw), token.Bytes)
|
|
}
|