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 ¶
- Variables
- func ParseConfig(src []byte, filename string, start hcl.Pos) (*hcl.File, hcl.Diagnostics)
- func ParseStringLiteralToken(tok Token) (string, hcl.Diagnostics)
- func ParseTraversalAbs(src []byte, filename string, start hcl.Pos) (hcl.Traversal, hcl.Diagnostics)
- func ValidIdentifier(s string) bool
- func Variables(expr Expression) []hcl.Traversal
- func VisitAll(node Node, f VisitFunc) hcl.Diagnostics
- func Walk(node Node, w Walker) hcl.Diagnostics
- type AnonSymbolExpr
- type Attribute
- type Attributes
- type BinaryOpExpr
- type Block
- type Blocks
- type Body
- func (b *Body) AttributeAtPos(pos hcl.Pos) *hcl.Attribute
- func (b *Body) BlocksAtPos(pos hcl.Pos) []*hcl.Block
- func (b *Body) Content(schema *hcl.BodySchema) (*hcl.BodyContent, hcl.Diagnostics)
- func (b *Body) InnermostBlockAtPos(pos hcl.Pos) *hcl.Block
- func (b *Body) JustAttributes() (hcl.Attributes, hcl.Diagnostics)
- func (b *Body) MissingItemRange() hcl.Range
- func (b *Body) OutermostBlockAtPos(pos hcl.Pos) *hcl.Block
- func (b *Body) OutermostExprAtPos(pos hcl.Pos) hcl.Expression
- func (b *Body) PartialContent(schema *hcl.BodySchema) (*hcl.BodyContent, hcl.Body, hcl.Diagnostics)
- func (b *Body) Range() hcl.Range
- type ChildScope
- type ConditionalExpr
- type Expression
- type File
- type ForExpr
- type FunctionCallDiagExtra
- type FunctionCallExpr
- type FunctionCallUnknownDiagExtra
- type IndexExpr
- type Keyword
- type LiteralValueExpr
- type Node
- type ObjectConsExpr
- type ObjectConsItem
- type ObjectConsKeyExpr
- func (e *ObjectConsKeyExpr) AsTraversal() hcl.Traversal
- func (e *ObjectConsKeyExpr) Range() hcl.Range
- func (e *ObjectConsKeyExpr) StartRange() hcl.Range
- func (e *ObjectConsKeyExpr) UnwrapExpression() Expression
- func (e *ObjectConsKeyExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (e *ObjectConsKeyExpr) Variables() []hcl.Traversal
- type Operation
- type ParenthesesExpr
- type RelativeTraversalExpr
- func (e *RelativeTraversalExpr) AsTraversal() hcl.Traversal
- func (e *RelativeTraversalExpr) Range() hcl.Range
- func (e *RelativeTraversalExpr) StartRange() hcl.Range
- func (e *RelativeTraversalExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (e *RelativeTraversalExpr) Variables() []hcl.Traversal
- type ScopeTraversalExpr
- type SplatExpr
- type TemplateExpr
- type TemplateJoinExpr
- type TemplateWrapExpr
- type Token
- type TokenType
- type Tokens
- type TupleConsExpr
- type UnaryOpExpr
- type VisitFunc
- type Walker
Constants ¶
This section is empty.
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, } )
Functions ¶
func ParseConfig ¶
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 ParseStringLiteralToken ¶
ParseStringLiteralToken processes the given token, which must be either a TokenQuotedLit or a TokenStringLit, returning the string resulting from resolving any escape sequences.
If any error diagnostics are returned, the returned string may be incomplete or otherwise invalid.
func ParseTraversalAbs ¶
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 ¶
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 ¶
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.
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 (e *AnonSymbolExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
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.
type Attributes ¶
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.
type Body ¶
type Body struct { Attributes Attributes Blocks Blocks SrcRange hcl.Range EndRange hcl.Range // Final token of the body (zero-length range) // 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)
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 (e *ConditionalExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
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 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) StartRange ¶
func (e *ForExpr) StartRange() hcl.Range
type FunctionCallDiagExtra ¶ added in v2.13.0
type FunctionCallDiagExtra interface { // CalledFunctionName returns the name of the function being called at // the time the diagnostic was generated, if any. Returns an empty string // if there is no known called function. CalledFunctionName() string // FunctionCallError returns the error value returned by the implementation // of the function being called, if any. Returns nil if the diagnostic was // not returned in response to a call error. // // Some errors related to calling functions are generated by HCL itself // rather than by the underlying function, in which case this method // will return nil. FunctionCallError() error }
FunctionCallDiagExtra is an interface implemented by the value in the "Extra" field of some diagnostics returned by FunctionCallExpr.Value, giving cooperating callers access to some machine-readable information about the call that a diagnostic relates to.
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 (e *FunctionCallExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*FunctionCallExpr) Variables ¶
func (e *FunctionCallExpr) Variables() []hcl.Traversal
type FunctionCallUnknownDiagExtra ¶ added in v2.20.0
type FunctionCallUnknownDiagExtra interface { CalledFunctionName() string CalledFunctionNamespace() string }
FunctionCallUnknownDiagExtra is an interface implemented by a value in the Extra field of some diagnostics to indicate when the error was caused by a call to an unknown function.
type IndexExpr ¶
type IndexExpr struct { Collection Expression Key Expression SrcRange hcl.Range OpenRange hcl.Range BracketRange hcl.Range }
func (*IndexExpr) StartRange ¶
func (e *IndexExpr) StartRange() hcl.Range
type LiteralValueExpr ¶
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 (e *LiteralValueExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
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 (e *ObjectConsExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
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 ForceNonLiteral bool }
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 (e *ObjectConsKeyExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*ObjectConsKeyExpr) Variables ¶
func (e *ObjectConsKeyExpr) Variables() []hcl.Traversal
type ParenthesesExpr ¶ added in v2.8.0
type ParenthesesExpr struct { Expression SrcRange hcl.Range }
ParenthesesExpr represents an expression written in grouping parentheses.
The parser takes care of the precedence effect of the parentheses, so the only purpose of this separate expression node is to capture the source range of the parentheses themselves, rather than the source range of the expression within. All of the other expression operations just pass through to the underlying expression.
func (*ParenthesesExpr) Range ¶ added in v2.8.0
func (e *ParenthesesExpr) Range() hcl.Range
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 (e *RelativeTraversalExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
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 (e *ScopeTraversalExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
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) StartRange ¶
func (e *SplatExpr) StartRange() hcl.Range
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 (e *TemplateJoinExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
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 (e *TemplateWrapExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*TemplateWrapExpr) Variables ¶
func (e *TemplateWrapExpr) Variables() []hcl.Traversal
type Token ¶
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 = ',' TokenDoubleColon 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' )
type Tokens ¶
type Tokens []Token
Tokens is a slice of Token.
func LexConfig ¶
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 ¶
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 ¶
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
Source 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.rl
- scan_tokens.rl
- structure.go
- structure_at_pos.go
- token.go
- token_type_string.go
- variables.go
- walk.go