2017-09-11 23:40:37 +00:00
|
|
|
package hclsyntax
|
2017-06-13 15:43:03 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Keyword []byte
|
|
|
|
|
|
|
|
var forKeyword = Keyword([]byte{'f', 'o', 'r'})
|
|
|
|
var inKeyword = Keyword([]byte{'i', 'n'})
|
|
|
|
var ifKeyword = Keyword([]byte{'i', 'f'})
|
2017-06-17 17:07:59 +00:00
|
|
|
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'})
|
2017-06-13 15:43:03 +00:00
|
|
|
|
|
|
|
func (kw Keyword) TokenMatches(token Token) bool {
|
|
|
|
if token.Type != TokenIdent {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return bytes.Equal([]byte(kw), token.Bytes)
|
|
|
|
}
|