github.com/hashicorp/hcl/v2@v2.20.0/hclsyntax/keywords.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package hclsyntax
     5  
     6  import (
     7  	"bytes"
     8  )
     9  
    10  type Keyword []byte
    11  
    12  var forKeyword = Keyword([]byte{'f', 'o', 'r'})
    13  var inKeyword = Keyword([]byte{'i', 'n'})
    14  var ifKeyword = Keyword([]byte{'i', 'f'})
    15  var elseKeyword = Keyword([]byte{'e', 'l', 's', 'e'})
    16  var endifKeyword = Keyword([]byte{'e', 'n', 'd', 'i', 'f'})
    17  var endforKeyword = Keyword([]byte{'e', 'n', 'd', 'f', 'o', 'r'})
    18  
    19  func (kw Keyword) TokenMatches(token Token) bool {
    20  	if token.Type != TokenIdent {
    21  		return false
    22  	}
    23  	return bytes.Equal([]byte(kw), token.Bytes)
    24  }