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

Function LexExpression

hclsyntax/public.go:172–178  ·  view source on GitHub ↗

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

(src []byte, filename string, start hcl.Pos)

Source from the content-addressed store, hash-verified

170// encodings or unrecognized characters, but full parsing is required to
171// detect _all_ syntax errors.
172func LexExpression(src []byte, filename string, start hcl.Pos) (Tokens, hcl.Diagnostics) {
173 // This is actually just the same thing as LexConfig, since configs
174 // and expressions lex in the same way.
175 tokens := scanTokens(src, filename, start, scanNormal)
176 diags := checkInvalidTokens(tokens)
177 return tokens, diags
178}
179
180// LexTemplate performs lexical analysis on the given buffer, treating it as a
181// standalone HCL template, and returns the resulting tokens.

Callers 3

ParseExpressionFunction · 0.85
ParseTraversalAbsFunction · 0.85
ParseTraversalPartialFunction · 0.85

Calls 2

scanTokensFunction · 0.85
checkInvalidTokensFunction · 0.85

Tested by

no test coverage detected