hcl2: github.com/hashicorp/hcl2/hcl/hclsyntax Index | Files

package hclsyntax

import "github.com/hashicorp/hcl2/hcl/hclsyntax"

Package hclsyntax contains the parser, AST, etc for HCL's native language, as opposed to the JSON variant.

In normal use applications should rarely depend on this package directly, instead preferring the higher-level interface of the main hcl package and its companion package hclparse.

Index

Package Files

diagnostics.go didyoumean.go doc.go expression.go expression_ops.go expression_template.go expression_vars.go file.go generate.go keywords.go navigation.go node.go parser.go parser_template.go parser_traversal.go peeker.go public.go scan_string_lit.go scan_tokens.go structure.go structure_at_pos.go token.go token_type_string.go variables.go walk.go

Variables

var (
    OpLogicalOr = &Operation{
        Impl: stdlib.OrFunc,
        Type: cty.Bool,
    }
    OpLogicalAnd = &Operation{
        Impl: stdlib.AndFunc,
        Type: cty.Bool,
    }
    OpLogicalNot = &Operation{
        Impl: stdlib.NotFunc,
        Type: cty.Bool,
    }

    OpEqual = &Operation{
        Impl: stdlib.EqualFunc,
        Type: cty.Bool,
    }
    OpNotEqual = &Operation{
        Impl: stdlib.NotEqualFunc,
        Type: cty.Bool,
    }

    OpGreaterThan = &Operation{
        Impl: stdlib.GreaterThanFunc,
        Type: cty.Bool,
    }
    OpGreaterThanOrEqual = &Operation{
        Impl: stdlib.GreaterThanOrEqualToFunc,
        Type: cty.Bool,
    }
    OpLessThan = &Operation{
        Impl: stdlib.LessThanFunc,
        Type: cty.Bool,
    }
    OpLessThanOrEqual = &Operation{
        Impl: stdlib.LessThanOrEqualToFunc,
        Type: cty.Bool,
    }

    OpAdd = &Operation{
        Impl: stdlib.AddFunc,
        Type: cty.Number,
    }
    OpSubtract = &Operation{
        Impl: stdlib.SubtractFunc,
        Type: cty.Number,
    }
    OpMultiply = &Operation{
        Impl: stdlib.MultiplyFunc,
        Type: cty.Number,
    }
    OpDivide = &Operation{
        Impl: stdlib.DivideFunc,
        Type: cty.Number,
    }
    OpModulo = &Operation{
        Impl: stdlib.ModuloFunc,
        Type: cty.Number,
    }
    OpNegate = &Operation{
        Impl: stdlib.NegateFunc,
        Type: cty.Number,
    }
)

func ParseConfig Uses

func ParseConfig(src []byte, filename string, start hcl.Pos) (*hcl.File, hcl.Diagnostics)

ParseConfig parses the given buffer as a whole HCL config file, returning a *hcl.File representing its contents. If HasErrors called on the returned diagnostics returns true, the returned body is likely to be incomplete and should therefore be used with care.

The body in the returned file has dynamic type *hclsyntax.Body, so callers may freely type-assert this to get access to the full hclsyntax API in situations where detailed access is required. However, most common use-cases should be served using the hcl.Body interface to ensure compatibility with other configurationg syntaxes, such as JSON.

func ParseTraversalAbs Uses

func ParseTraversalAbs(src []byte, filename string, start hcl.Pos) (hcl.Traversal, hcl.Diagnostics)

ParseTraversalAbs parses the given buffer as a standalone absolute traversal.

Parsing as a traversal is more limited than parsing as an expession since it allows only attribute and indexing operations on variables. Traverals are useful as a syntax for referring to objects without necessarily evaluating them.

func ValidIdentifier Uses

func ValidIdentifier(s string) bool

ValidIdentifier tests if the given string could be a valid identifier in a native syntax expression.

This is useful when accepting names from the user that will be used as variable or attribute names in the scope, to ensure that any name chosen will be traversable using the variable or attribute traversal syntax.

func Variables Uses

func Variables(expr Expression) []hcl.Traversal

Variables returns all of the variables referenced within a given experssion.

This is the implementation of the "Variables" method on every native expression.

func VisitAll Uses

func VisitAll(node Node, f VisitFunc) hcl.Diagnostics

VisitAll is a basic way to traverse the AST beginning with a particular node. The given function will be called once for each AST node in depth-first order, but no context is provided about the shape of the tree.

The VisitFunc may return diagnostics, in which case they will be accumulated and returned as a single set.

func Walk Uses

func Walk(node Node, w Walker) hcl.Diagnostics

Walk is a more complex way to traverse the AST starting with a particular node, which provides information about the tree structure via separate Enter and Exit functions.

type AnonSymbolExpr Uses

type AnonSymbolExpr struct {
    SrcRange hcl.Range
    // contains filtered or unexported fields
}

AnonSymbolExpr is used as a placeholder for a value in an expression that can be applied dynamically to any value at runtime.

This is a rather odd, synthetic expression. It is used as part of the representation of splat expressions as a placeholder for the current item being visited in the splat evaluation.

AnonSymbolExpr cannot be evaluated in isolation. If its Value is called directly then cty.DynamicVal will be returned. Instead, it is evaluated in terms of another node (i.e. a splat expression) which temporarily assigns it a value.

func (*AnonSymbolExpr) Range Uses

func (e *AnonSymbolExpr) Range() hcl.Range

func (*AnonSymbolExpr) StartRange Uses

func (e *AnonSymbolExpr) StartRange() hcl.Range

func (*AnonSymbolExpr) Value Uses

func (e *AnonSymbolExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*AnonSymbolExpr) Variables Uses

func (e *AnonSymbolExpr) Variables() []hcl.Traversal

type Attribute Uses

type Attribute struct {
    Name string
    Expr Expression

    SrcRange    hcl.Range
    NameRange   hcl.Range
    EqualsRange hcl.Range
}

Attribute represents a single attribute definition within a body.

func (*Attribute) AsHCLAttribute Uses

func (a *Attribute) AsHCLAttribute() *hcl.Attribute

AsHCLAttribute returns the block data expressed as a *hcl.Attribute.

func (*Attribute) Range Uses

func (a *Attribute) Range() hcl.Range

type Attributes Uses

type Attributes map[string]*Attribute

Attributes is the collection of attribute definitions within a body.

func (Attributes) Range Uses

func (a Attributes) Range() hcl.Range

Range returns the range of some arbitrary point within the set of attributes, or an invalid range if there are no attributes.

This is provided only to complete the Node interface, but has no practical use.

type BinaryOpExpr Uses

type BinaryOpExpr struct {
    LHS Expression
    Op  *Operation
    RHS Expression

    SrcRange hcl.Range
}

func (*BinaryOpExpr) Range Uses

func (e *BinaryOpExpr) Range() hcl.Range

func (*BinaryOpExpr) StartRange Uses

func (e *BinaryOpExpr) StartRange() hcl.Range

func (*BinaryOpExpr) Value Uses

func (e *BinaryOpExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*BinaryOpExpr) Variables Uses

func (e *BinaryOpExpr) Variables() []hcl.Traversal

type Block Uses

type Block struct {
    Type   string
    Labels []string
    Body   *Body

    TypeRange       hcl.Range
    LabelRanges     []hcl.Range
    OpenBraceRange  hcl.Range
    CloseBraceRange hcl.Range
}

Block represents a nested block structure

func (*Block) AsHCLBlock Uses

func (b *Block) AsHCLBlock() *hcl.Block

AsHCLBlock returns the block data expressed as a *hcl.Block.

func (*Block) DefRange Uses

func (b *Block) DefRange() hcl.Range

func (*Block) Range Uses

func (b *Block) Range() hcl.Range

type Blocks Uses

type Blocks []*Block

Blocks is the list of nested blocks within a body.

func (Blocks) Range Uses

func (bs Blocks) Range() hcl.Range

Range returns the range of some arbitrary point within the list of blocks, or an invalid range if there are no blocks.

This is provided only to complete the Node interface, but has no practical use.

type Body Uses

type Body struct {
    Attributes Attributes
    Blocks     Blocks

    SrcRange hcl.Range
    EndRange hcl.Range // Final token of the body, for reporting missing items
    // contains filtered or unexported fields
}

Body is the implementation of hcl.Body for the HCL native syntax.

func (*Body) AttributeAtPos Uses

func (b *Body) AttributeAtPos(pos hcl.Pos) *hcl.Attribute

AttributeAtPos implements the method of the same name for an *hcl.File that is backed by a *Body.

func (*Body) BlocksAtPos Uses

func (b *Body) BlocksAtPos(pos hcl.Pos) []*hcl.Block

BlocksAtPos implements the method of the same name for an *hcl.File that is backed by a *Body.

func (*Body) Content Uses

func (b *Body) Content(schema *hcl.BodySchema) (*hcl.BodyContent, hcl.Diagnostics)

func (*Body) InnermostBlockAtPos Uses

func (b *Body) InnermostBlockAtPos(pos hcl.Pos) *hcl.Block

InnermostBlockAtPos implements the method of the same name for an *hcl.File that is backed by a *Body.

func (*Body) JustAttributes Uses

func (b *Body) JustAttributes() (hcl.Attributes, hcl.Diagnostics)

func (*Body) MissingItemRange Uses

func (b *Body) MissingItemRange() hcl.Range

func (*Body) OutermostBlockAtPos Uses

func (b *Body) OutermostBlockAtPos(pos hcl.Pos) *hcl.Block

OutermostBlockAtPos implements the method of the same name for an *hcl.File that is backed by a *Body.

func (*Body) OutermostExprAtPos Uses

func (b *Body) OutermostExprAtPos(pos hcl.Pos) hcl.Expression

OutermostExprAtPos implements the method of the same name for an *hcl.File that is backed by a *Body.

func (*Body) PartialContent Uses

func (b *Body) PartialContent(schema *hcl.BodySchema) (*hcl.BodyContent, hcl.Body, hcl.Diagnostics)

func (*Body) Range Uses

func (b *Body) Range() hcl.Range

type ChildScope Uses

type ChildScope struct {
    LocalNames map[string]struct{}
    Expr       Expression
}

ChildScope is a synthetic AST node that is visited during a walk to indicate that its descendent will be evaluated in a child scope, which may mask certain variables from the parent scope as locals.

ChildScope nodes don't really exist in the AST, but are rather synthesized on the fly during walk. Therefore it doesn't do any good to transform them; instead, transform either parent node that created a scope or the expression that the child scope struct wraps.

func (ChildScope) Range Uses

func (e ChildScope) Range() hcl.Range

Range returns the range of the expression that the ChildScope is encapsulating. It isn't really very useful to call Range on a ChildScope.

type ConditionalExpr Uses

type ConditionalExpr struct {
    Condition   Expression
    TrueResult  Expression
    FalseResult Expression

    SrcRange hcl.Range
}

func (*ConditionalExpr) Range Uses

func (e *ConditionalExpr) Range() hcl.Range

func (*ConditionalExpr) StartRange Uses

func (e *ConditionalExpr) StartRange() hcl.Range

func (*ConditionalExpr) Value Uses

func (e *ConditionalExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*ConditionalExpr) Variables Uses

func (e *ConditionalExpr) Variables() []hcl.Traversal

type Expression Uses

type Expression interface {
    Node

    Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
    Variables() []hcl.Traversal
    StartRange() hcl.Range
}

Expression is the abstract type for nodes that behave as HCL expressions.

func ParseExpression Uses

func ParseExpression(src []byte, filename string, start hcl.Pos) (Expression, hcl.Diagnostics)

ParseExpression parses the given buffer as a standalone HCL expression, returning it as an instance of Expression.

func ParseTemplate Uses

func ParseTemplate(src []byte, filename string, start hcl.Pos) (Expression, hcl.Diagnostics)

ParseTemplate parses the given buffer as a standalone HCL template, returning it as an instance of Expression.

type File Uses

type File struct {
    Body  *Body
    Bytes []byte
}

File is the top-level object resulting from parsing a configuration file.

func (*File) AsHCLFile Uses

func (f *File) AsHCLFile() *hcl.File

type ForExpr Uses

type ForExpr struct {
    KeyVar string // empty if ignoring the key
    ValVar string

    CollExpr Expression

    KeyExpr  Expression // nil when producing a tuple
    ValExpr  Expression
    CondExpr Expression // null if no "if" clause is present

    Group bool // set if the ellipsis is used on the value in an object for

    SrcRange   hcl.Range
    OpenRange  hcl.Range
    CloseRange hcl.Range
}

ForExpr represents iteration constructs:

tuple = [for i, v in list: upper(v) if i > 2]
object = {for k, v in map: k => upper(v)}
object_of_tuples = {for v in list: v.key: v...}

func (*ForExpr) Range Uses

func (e *ForExpr) Range() hcl.Range

func (*ForExpr) StartRange Uses

func (e *ForExpr) StartRange() hcl.Range

func (*ForExpr) Value Uses

func (e *ForExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*ForExpr) Variables Uses

func (e *ForExpr) Variables() []hcl.Traversal

type FunctionCallExpr Uses

type FunctionCallExpr struct {
    Name string
    Args []Expression

    // If true, the final argument should be a tuple, list or set which will
    // expand to be one argument per element.
    ExpandFinal bool

    NameRange       hcl.Range
    OpenParenRange  hcl.Range
    CloseParenRange hcl.Range
}

FunctionCallExpr is an Expression that calls a function from the EvalContext and returns its result.

func (*FunctionCallExpr) ExprCall Uses

func (e *FunctionCallExpr) ExprCall() *hcl.StaticCall

Implementation for hcl.ExprCall.

func (*FunctionCallExpr) Range Uses

func (e *FunctionCallExpr) Range() hcl.Range

func (*FunctionCallExpr) StartRange Uses

func (e *FunctionCallExpr) StartRange() hcl.Range

func (*FunctionCallExpr) Value Uses

func (e *FunctionCallExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*FunctionCallExpr) Variables Uses

func (e *FunctionCallExpr) Variables() []hcl.Traversal

type IndexExpr Uses

type IndexExpr struct {
    Collection Expression
    Key        Expression

    SrcRange  hcl.Range
    OpenRange hcl.Range
}

func (*IndexExpr) Range Uses

func (e *IndexExpr) Range() hcl.Range

func (*IndexExpr) StartRange Uses

func (e *IndexExpr) StartRange() hcl.Range

func (*IndexExpr) Value Uses

func (e *IndexExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*IndexExpr) Variables Uses

func (e *IndexExpr) Variables() []hcl.Traversal

type Keyword Uses

type Keyword []byte

func (Keyword) TokenMatches Uses

func (kw Keyword) TokenMatches(token Token) bool

type LiteralValueExpr Uses

type LiteralValueExpr struct {
    Val      cty.Value
    SrcRange hcl.Range
}

LiteralValueExpr is an expression that just always returns a given value.

func (*LiteralValueExpr) AsTraversal Uses

func (e *LiteralValueExpr) AsTraversal() hcl.Traversal

Implementation for hcl.AbsTraversalForExpr.

func (*LiteralValueExpr) Range Uses

func (e *LiteralValueExpr) Range() hcl.Range

func (*LiteralValueExpr) StartRange Uses

func (e *LiteralValueExpr) StartRange() hcl.Range

func (*LiteralValueExpr) Value Uses

func (e *LiteralValueExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*LiteralValueExpr) Variables Uses

func (e *LiteralValueExpr) Variables() []hcl.Traversal

type Node Uses

type Node interface {
    Range() hcl.Range
    // contains filtered or unexported methods
}

Node is the abstract type that every AST node implements.

This is a closed interface, so it cannot be implemented from outside of this package.

type ObjectConsExpr Uses

type ObjectConsExpr struct {
    Items []ObjectConsItem

    SrcRange  hcl.Range
    OpenRange hcl.Range
}

func (*ObjectConsExpr) ExprMap Uses

func (e *ObjectConsExpr) ExprMap() []hcl.KeyValuePair

Implementation for hcl.ExprMap

func (*ObjectConsExpr) Range Uses

func (e *ObjectConsExpr) Range() hcl.Range

func (*ObjectConsExpr) StartRange Uses

func (e *ObjectConsExpr) StartRange() hcl.Range

func (*ObjectConsExpr) Value Uses

func (e *ObjectConsExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*ObjectConsExpr) Variables Uses

func (e *ObjectConsExpr) Variables() []hcl.Traversal

type ObjectConsItem Uses

type ObjectConsItem struct {
    KeyExpr   Expression
    ValueExpr Expression
}

type ObjectConsKeyExpr Uses

type ObjectConsKeyExpr struct {
    Wrapped Expression
}

ObjectConsKeyExpr is a special wrapper used only for ObjectConsExpr keys, which deals with the special case that a naked identifier in that position must be interpreted as a literal string rather than evaluated directly.

func (*ObjectConsKeyExpr) AsTraversal Uses

func (e *ObjectConsKeyExpr) AsTraversal() hcl.Traversal

Implementation for hcl.AbsTraversalForExpr.

func (*ObjectConsKeyExpr) Range Uses

func (e *ObjectConsKeyExpr) Range() hcl.Range

func (*ObjectConsKeyExpr) StartRange Uses

func (e *ObjectConsKeyExpr) StartRange() hcl.Range

func (*ObjectConsKeyExpr) UnwrapExpression Uses

func (e *ObjectConsKeyExpr) UnwrapExpression() Expression

func (*ObjectConsKeyExpr) Value Uses

func (e *ObjectConsKeyExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*ObjectConsKeyExpr) Variables Uses

func (e *ObjectConsKeyExpr) Variables() []hcl.Traversal

type Operation Uses

type Operation struct {
    Impl function.Function
    Type cty.Type
}

type RelativeTraversalExpr Uses

type RelativeTraversalExpr struct {
    Source    Expression
    Traversal hcl.Traversal
    SrcRange  hcl.Range
}

RelativeTraversalExpr is an Expression that retrieves a value from another value using a _relative_ traversal.

func (*RelativeTraversalExpr) AsTraversal Uses

func (e *RelativeTraversalExpr) AsTraversal() hcl.Traversal

Implementation for hcl.AbsTraversalForExpr.

func (*RelativeTraversalExpr) Range Uses

func (e *RelativeTraversalExpr) Range() hcl.Range

func (*RelativeTraversalExpr) StartRange Uses

func (e *RelativeTraversalExpr) StartRange() hcl.Range

func (*RelativeTraversalExpr) Value Uses

func (e *RelativeTraversalExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*RelativeTraversalExpr) Variables Uses

func (e *RelativeTraversalExpr) Variables() []hcl.Traversal

type ScopeTraversalExpr Uses

type ScopeTraversalExpr struct {
    Traversal hcl.Traversal
    SrcRange  hcl.Range
}

ScopeTraversalExpr is an Expression that retrieves a value from the scope using a traversal.

func (*ScopeTraversalExpr) AsTraversal Uses

func (e *ScopeTraversalExpr) AsTraversal() hcl.Traversal

Implementation for hcl.AbsTraversalForExpr.

func (*ScopeTraversalExpr) Range Uses

func (e *ScopeTraversalExpr) Range() hcl.Range

func (*ScopeTraversalExpr) StartRange Uses

func (e *ScopeTraversalExpr) StartRange() hcl.Range

func (*ScopeTraversalExpr) Value Uses

func (e *ScopeTraversalExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*ScopeTraversalExpr) Variables Uses

func (e *ScopeTraversalExpr) Variables() []hcl.Traversal

type SplatExpr Uses

type SplatExpr struct {
    Source Expression
    Each   Expression
    Item   *AnonSymbolExpr

    SrcRange    hcl.Range
    MarkerRange hcl.Range
}

func (*SplatExpr) Range Uses

func (e *SplatExpr) Range() hcl.Range

func (*SplatExpr) StartRange Uses

func (e *SplatExpr) StartRange() hcl.Range

func (*SplatExpr) Value Uses

func (e *SplatExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*SplatExpr) Variables Uses

func (e *SplatExpr) Variables() []hcl.Traversal

type TemplateExpr Uses

type TemplateExpr struct {
    Parts []Expression

    SrcRange hcl.Range
}

func (*TemplateExpr) IsStringLiteral Uses

func (e *TemplateExpr) IsStringLiteral() bool

IsStringLiteral returns true if and only if the template consists only of single string literal, as would be created for a simple quoted string like "foo".

If this function returns true, then calling Value on the same expression with a nil EvalContext will return the literal value.

Note that "${"foo"}", "${1}", etc aren't considered literal values for the purposes of this method, because the intent of this method is to identify situations where the user seems to be explicitly intending literal string interpretation, not situations that result in literals as a technicality of the template expression unwrapping behavior.

func (*TemplateExpr) Range Uses

func (e *TemplateExpr) Range() hcl.Range

func (*TemplateExpr) StartRange Uses

func (e *TemplateExpr) StartRange() hcl.Range

func (*TemplateExpr) Value Uses

func (e *TemplateExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*TemplateExpr) Variables Uses

func (e *TemplateExpr) Variables() []hcl.Traversal

type TemplateJoinExpr Uses

type TemplateJoinExpr struct {
    Tuple Expression
}

TemplateJoinExpr is used to convert tuples of strings produced by template constructs (i.e. for loops) into flat strings, by converting the values tos strings and joining them. This AST node is not used directly; it's produced as part of the AST of a "for" loop in a template.

func (*TemplateJoinExpr) Range Uses

func (e *TemplateJoinExpr) Range() hcl.Range

func (*TemplateJoinExpr) StartRange Uses

func (e *TemplateJoinExpr) StartRange() hcl.Range

func (*TemplateJoinExpr) Value Uses

func (e *TemplateJoinExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*TemplateJoinExpr) Variables Uses

func (e *TemplateJoinExpr) Variables() []hcl.Traversal

type TemplateWrapExpr Uses

type TemplateWrapExpr struct {
    Wrapped Expression

    SrcRange hcl.Range
}

TemplateWrapExpr is used instead of a TemplateExpr when a template consists _only_ of a single interpolation sequence. In that case, the template's result is the single interpolation's result, verbatim with no type conversions.

func (*TemplateWrapExpr) Range Uses

func (e *TemplateWrapExpr) Range() hcl.Range

func (*TemplateWrapExpr) StartRange Uses

func (e *TemplateWrapExpr) StartRange() hcl.Range

func (*TemplateWrapExpr) Value Uses

func (e *TemplateWrapExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*TemplateWrapExpr) Variables Uses

func (e *TemplateWrapExpr) Variables() []hcl.Traversal

type Token Uses

type Token struct {
    Type  TokenType
    Bytes []byte
    Range hcl.Range
}

Token represents a sequence of bytes from some HCL code that has been tagged with a type and its range within the source file.

type TokenType Uses

type TokenType rune

TokenType is an enumeration used for the Type field on Token.

const (
    TokenOBrace   TokenType = '{'
    TokenCBrace   TokenType = '}'
    TokenOBrack   TokenType = '['
    TokenCBrack   TokenType = ']'
    TokenOParen   TokenType = '('
    TokenCParen   TokenType = ')'
    TokenOQuote   TokenType = '«'
    TokenCQuote   TokenType = '»'
    TokenOHeredoc TokenType = 'H'
    TokenCHeredoc TokenType = 'h'

    TokenStar    TokenType = '*'
    TokenSlash   TokenType = '/'
    TokenPlus    TokenType = '+'
    TokenMinus   TokenType = '-'
    TokenPercent TokenType = '%'

    TokenEqual         TokenType = '='
    TokenEqualOp       TokenType = '≔'
    TokenNotEqual      TokenType = '≠'
    TokenLessThan      TokenType = '<'
    TokenLessThanEq    TokenType = '≤'
    TokenGreaterThan   TokenType = '>'
    TokenGreaterThanEq TokenType = '≥'

    TokenAnd  TokenType = '∧'
    TokenOr   TokenType = '∨'
    TokenBang TokenType = '!'

    TokenDot   TokenType = '.'
    TokenComma TokenType = ','

    TokenEllipsis TokenType = '…'
    TokenFatArrow TokenType = '⇒'

    TokenQuestion TokenType = '?'
    TokenColon    TokenType = ':'

    TokenTemplateInterp  TokenType = '∫'
    TokenTemplateControl TokenType = 'λ'
    TokenTemplateSeqEnd  TokenType = '∎'

    TokenQuotedLit TokenType = 'Q' // might contain backslash escapes
    TokenStringLit TokenType = 'S' // cannot contain backslash escapes
    TokenNumberLit TokenType = 'N'
    TokenIdent     TokenType = 'I'

    TokenComment TokenType = 'C'

    TokenNewline TokenType = '\n'
    TokenEOF     TokenType = '␄'

    TokenBitwiseAnd    TokenType = '&'
    TokenBitwiseOr     TokenType = '|'
    TokenBitwiseNot    TokenType = '~'
    TokenBitwiseXor    TokenType = '^'
    TokenStarStar      TokenType = '➚'
    TokenApostrophe    TokenType = '\''
    TokenBacktick      TokenType = '`'
    TokenSemicolon     TokenType = ';'
    TokenTabs          TokenType = '␉'
    TokenInvalid       TokenType = '�'
    TokenBadUTF8       TokenType = '💩'
    TokenQuotedNewline TokenType = '␤'

    // TokenNil is a placeholder for when a token is required but none is
    // available, e.g. when reporting errors. The scanner will never produce
    // this as part of a token stream.
    TokenNil TokenType = '\x00'
)

func (TokenType) GoString Uses

func (t TokenType) GoString() string

func (TokenType) String Uses

func (i TokenType) String() string

type Tokens Uses

type Tokens []Token

Tokens is a slice of Token.

func LexConfig Uses

func LexConfig(src []byte, filename string, start hcl.Pos) (Tokens, hcl.Diagnostics)

LexConfig performs lexical analysis on the given buffer, treating it as a whole HCL config file, and returns the resulting tokens.

Only minimal validation is done during lexical analysis, so the returned diagnostics may include errors about lexical issues such as bad character encodings or unrecognized characters, but full parsing is required to detect _all_ syntax errors.

func LexExpression Uses

func LexExpression(src []byte, filename string, start hcl.Pos) (Tokens, hcl.Diagnostics)

LexExpression performs lexical analysis on the given buffer, treating it as a standalone HCL expression, and returns the resulting tokens.

Only minimal validation is done during lexical analysis, so the returned diagnostics may include errors about lexical issues such as bad character encodings or unrecognized characters, but full parsing is required to detect _all_ syntax errors.

func LexTemplate Uses

func LexTemplate(src []byte, filename string, start hcl.Pos) (Tokens, hcl.Diagnostics)

LexTemplate performs lexical analysis on the given buffer, treating it as a standalone HCL template, and returns the resulting tokens.

Only minimal validation is done during lexical analysis, so the returned diagnostics may include errors about lexical issues such as bad character encodings or unrecognized characters, but full parsing is required to detect _all_ syntax errors.

type TupleConsExpr Uses

type TupleConsExpr struct {
    Exprs []Expression

    SrcRange  hcl.Range
    OpenRange hcl.Range
}

func (*TupleConsExpr) ExprList Uses

func (e *TupleConsExpr) ExprList() []hcl.Expression

Implementation for hcl.ExprList

func (*TupleConsExpr) Range Uses

func (e *TupleConsExpr) Range() hcl.Range

func (*TupleConsExpr) StartRange Uses

func (e *TupleConsExpr) StartRange() hcl.Range

func (*TupleConsExpr) Value Uses

func (e *TupleConsExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*TupleConsExpr) Variables Uses

func (e *TupleConsExpr) Variables() []hcl.Traversal

type UnaryOpExpr Uses

type UnaryOpExpr struct {
    Op  *Operation
    Val Expression

    SrcRange    hcl.Range
    SymbolRange hcl.Range
}

func (*UnaryOpExpr) Range Uses

func (e *UnaryOpExpr) Range() hcl.Range

func (*UnaryOpExpr) StartRange Uses

func (e *UnaryOpExpr) StartRange() hcl.Range

func (*UnaryOpExpr) Value Uses

func (e *UnaryOpExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*UnaryOpExpr) Variables Uses

func (e *UnaryOpExpr) Variables() []hcl.Traversal

type VisitFunc Uses

type VisitFunc func(node Node) hcl.Diagnostics

VisitFunc is the callback signature for VisitAll.

type Walker Uses

type Walker interface {
    Enter(node Node) hcl.Diagnostics
    Exit(node Node) hcl.Diagnostics
}

Walker is an interface used with Walk.

Package hclsyntax imports 16 packages (graph) and is imported by 68 packages. Updated 2019-08-06. Refresh now. Tools for package owners.