MCPcopy
hub / github.com/hashicorp/hcl / NewExpressionRaw

Function NewExpressionRaw

hclwrite/ast_expression.go:39–48  ·  view source on GitHub ↗

NewExpressionRaw constructs an expression containing the given raw tokens. There is no automatic validation that the given tokens produce a valid expression. Callers of thus function must take care to produce invalid expression tokens. Where possible, use the higher-level functions NewExpressionLit

(tokens Tokens)

Source from the content-addressed store, hash-verified

37// contains a subslice that would normally be interpreted as a traversal under
38// parsing.
39func NewExpressionRaw(tokens Tokens) *Expression {
40 expr := newExpression()
41 // We copy the tokens here in order to make sure that later mutations
42 // by the caller don't inadvertently cause our expression to become
43 // invalid.
44 copyTokens := make(Tokens, len(tokens))
45 copy(copyTokens, tokens)
46 expr.children.AppendUnstructuredTokens(copyTokens)
47 return expr
48}
49
50// NewExpressionLiteral constructs an an expression that represents the given
51// literal value.

Callers 1

SetAttributeRawMethod · 0.85

Calls 2

newExpressionFunction · 0.85

Tested by

no test coverage detected