hcl/hclsyntax/keywords.go
Martin Atkins 6c4344623b Unfold the "hcl" directory up into the root
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.
2019-09-09 16:08:19 -07:00

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)
}