diff --git a/zcl/zclsyntax/keywords.go b/zcl/zclsyntax/keywords.go new file mode 100644 index 0000000..83e1109 --- /dev/null +++ b/zcl/zclsyntax/keywords.go @@ -0,0 +1,18 @@ +package zclsyntax + +import ( + "bytes" +) + +type Keyword []byte + +var forKeyword = Keyword([]byte{'f', 'o', 'r'}) +var inKeyword = Keyword([]byte{'i', 'n'}) +var ifKeyword = Keyword([]byte{'i', 'f'}) + +func (kw Keyword) TokenMatches(token Token) bool { + if token.Type != TokenIdent { + return false + } + return bytes.Equal([]byte(kw), token.Bytes) +}