MCPcopy
hub / github.com/google/go-jsonnet / Parse

Function Parse

internal/parser/parser.go:1385–1400  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Parse parses a slice of tokens into a parse tree. Any fodder after the final token is returned as well.

(t Tokens)

Source from the content-addressed store, hash-verified

1383// Parse parses a slice of tokens into a parse tree. Any fodder after the final token is
1384// returned as well.
1385func Parse(t Tokens) (ast.Node, ast.Fodder, errors.StaticError) {
1386 p := makeParser(t)
1387 expr, err := p.parse(iast.MaxPrecedence)
1388 if err != nil {
1389 return nil, nil, err
1390 }
1391 eof := p.peek()
1392
1393 if eof.kind != tokenEndOfFile {
1394 return nil, nil, errors.MakeStaticError(fmt.Sprintf("Did not expect: %v", eof), eof.loc)
1395 }
1396
1397 addContext(expr, &topLevelContext, anonymous)
1398
1399 return expr, eof.fodder, nil
1400}
1401
1402// SnippetToRawAST converts a Jsonnet code snippet to an AST (without any transformations).
1403// Any fodder after the final token is returned as well.

Callers 3

TestParserFunction · 0.85
TestParserErrorsFunction · 0.85
SnippetToRawASTFunction · 0.85

Calls 5

MakeStaticErrorFunction · 0.92
makeParserFunction · 0.85
addContextFunction · 0.85
parseMethod · 0.80
peekMethod · 0.45

Tested by 2

TestParserFunction · 0.68
TestParserErrorsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…