hclsyntax

package
Version: v0.0.0-...-fb75b32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2019 License: MPL-2.0 Imports: 16 Imported by: 63

Documentation

Overview

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

Constants

This section is empty.

Variables

View Source
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,
	}
)

Functions

func ParseConfig

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

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

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

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

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

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.

Types

type AnonSymbolExpr

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

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

func (*AnonSymbolExpr) StartRange

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

func (*AnonSymbolExpr) Value

func (*AnonSymbolExpr) Variables

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

type Attribute

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

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

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

func (*Attribute) Range

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

type Attributes

type Attributes map[string]*Attribute

Attributes is the collection of attribute definitions within a body.

func (Attributes) Range

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

type BinaryOpExpr struct {
	LHS Expression
	Op  *Operation
	RHS Expression

	SrcRange hcl.Range
}

func (*BinaryOpExpr) Range

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

func (*BinaryOpExpr) StartRange

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

func (*BinaryOpExpr) Value

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

func (*BinaryOpExpr) Variables

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

type Block

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

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

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

func (*Block) DefRange

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

func (*Block) Range

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

type Blocks

type Blocks []*Block

Blocks is the list of nested blocks within a body.

func (Blocks) Range

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

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

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

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

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

func (*Body) InnermostBlockAtPos

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

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

func (*Body) MissingItemRange

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

func (*Body) OutermostBlockAtPos

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

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

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

func (*Body) Range

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

type ChildScope

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

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

type ConditionalExpr struct {
	Condition   Expression
	TrueResult  Expression
	FalseResult Expression

	SrcRange hcl.Range
}

func (*ConditionalExpr) Range

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

func (*ConditionalExpr) StartRange

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

func (*ConditionalExpr) Value

func (*ConditionalExpr) Variables

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

type Expression

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

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

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

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

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

func (*File) AsHCLFile

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

type ForExpr

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

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

func (*ForExpr) StartRange

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

func (*ForExpr) Value

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

func (*ForExpr) Variables

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

type FunctionCallExpr

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

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

Implementation for hcl.ExprCall.

func (*FunctionCallExpr) Range

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

func (*FunctionCallExpr) StartRange

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

func (*FunctionCallExpr) Value

func (*FunctionCallExpr) Variables

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

type IndexExpr

type IndexExpr struct {
	Collection Expression
	Key        Expression

	SrcRange  hcl.Range
	OpenRange hcl.Range
}

func (*IndexExpr) Range

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

func (*IndexExpr) StartRange

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

func (*IndexExpr) Value

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

func (*IndexExpr) Variables

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

type Keyword

type Keyword []byte

func (Keyword) TokenMatches

func (kw Keyword) TokenMatches(token Token) bool

type LiteralValueExpr

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

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

func (*LiteralValueExpr) AsTraversal

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

Implementation for hcl.AbsTraversalForExpr.

func (*LiteralValueExpr) Range

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

func (*LiteralValueExpr) StartRange

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

func (*LiteralValueExpr) Value

func (*LiteralValueExpr) Variables

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

type Node

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

type ObjectConsExpr struct {
	Items []ObjectConsItem

	SrcRange  hcl.Range
	OpenRange hcl.Range
}

func (*ObjectConsExpr) ExprMap

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

Implementation for hcl.ExprMap

func (*ObjectConsExpr) Range

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

func (*ObjectConsExpr) StartRange

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

func (*ObjectConsExpr) Value

func (*ObjectConsExpr) Variables

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

type ObjectConsItem

type ObjectConsItem struct {
	KeyExpr   Expression
	ValueExpr Expression
}

type ObjectConsKeyExpr

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

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

Implementation for hcl.AbsTraversalForExpr.

func (*ObjectConsKeyExpr) Range

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

func (*ObjectConsKeyExpr) StartRange

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

func (*ObjectConsKeyExpr) UnwrapExpression

func (e *ObjectConsKeyExpr) UnwrapExpression() Expression

func (*ObjectConsKeyExpr) Value

func (*ObjectConsKeyExpr) Variables

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

type Operation

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

type RelativeTraversalExpr

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

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

Implementation for hcl.AbsTraversalForExpr.

func (*RelativeTraversalExpr) Range

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

func (*RelativeTraversalExpr) StartRange

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

func (*RelativeTraversalExpr) Value

func (*RelativeTraversalExpr) Variables

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

type ScopeTraversalExpr

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

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

Implementation for hcl.AbsTraversalForExpr.

func (*ScopeTraversalExpr) Range

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

func (*ScopeTraversalExpr) StartRange

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

func (*ScopeTraversalExpr) Value

func (*ScopeTraversalExpr) Variables

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

type SplatExpr

type SplatExpr struct {
	Source Expression
	Each   Expression
	Item   *AnonSymbolExpr

	SrcRange    hcl.Range
	MarkerRange hcl.Range
}

func (*SplatExpr) Range

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

func (*SplatExpr) StartRange

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

func (*SplatExpr) Value

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

func (*SplatExpr) Variables

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

type TemplateExpr

type TemplateExpr struct {
	Parts []Expression

	SrcRange hcl.Range
}

func (*TemplateExpr) IsStringLiteral

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

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

func (*TemplateExpr) StartRange

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

func (*TemplateExpr) Value

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

func (*TemplateExpr) Variables

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

type TemplateJoinExpr

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

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

func (*TemplateJoinExpr) StartRange

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

func (*TemplateJoinExpr) Value

func (*TemplateJoinExpr) Variables

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

type TemplateWrapExpr

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

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

func (*TemplateWrapExpr) StartRange

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

func (*TemplateWrapExpr) Value

func (*TemplateWrapExpr) Variables

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

type Token

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

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

func (t TokenType) GoString() string

func (TokenType) String

func (i TokenType) String() string

type Tokens

type Tokens []Token

Tokens is a slice of Token.

func LexConfig

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

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

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

type TupleConsExpr struct {
	Exprs []Expression

	SrcRange  hcl.Range
	OpenRange hcl.Range
}

func (*TupleConsExpr) ExprList

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

Implementation for hcl.ExprList

func (*TupleConsExpr) Range

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

func (*TupleConsExpr) StartRange

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

func (*TupleConsExpr) Value

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

func (*TupleConsExpr) Variables

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

type UnaryOpExpr

type UnaryOpExpr struct {
	Op  *Operation
	Val Expression

	SrcRange    hcl.Range
	SymbolRange hcl.Range
}

func (*UnaryOpExpr) Range

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

func (*UnaryOpExpr) StartRange

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

func (*UnaryOpExpr) Value

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

func (*UnaryOpExpr) Variables

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

type VisitFunc

type VisitFunc func(node Node) hcl.Diagnostics

VisitFunc is the callback signature for VisitAll.

type Walker

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

Walker is an interface used with Walk.

Directories

Path Synopsis
fuzz

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL