Documentation
¶
Overview ¶
Package parser reads Jsonnet files and parses them into AST nodes.
Index ¶
- func Children(node ast.Node) []ast.Node
- func DirectChildren(node ast.Node) []ast.Node
- func IsValidIdentifier(str string) bool
- func Parse(t Tokens) (ast.Node, ast.Fodder, errors.StaticError)
- func SnippetToRawAST(diagnosticFilename ast.DiagnosticFileName, importedFilename, snippet string) (ast.Node, ast.Fodder, error)
- func StringEscape(s string, single bool) string
- func StringUnescape(loc *ast.LocationRange, s string) (string, error)
- type Tokens
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Children ¶
Children returns all children of a node. It supports ASTs before and after desugaring.
func DirectChildren ¶ added in v0.16.0
DirectChildren are children of AST node that are executed in the same context and environment as their parent. It supports ASTs before and after desugaring.
They must satisfy the following rules: * (no-delayed-evaluation) They are evaluated when their parent is evaluated or never. * (no-indirect-evaluation) They cannot be evaluated during evaluation of any non-direct children * (same-environment) They must be evaluated in the same environment as their parent
func IsValidIdentifier ¶ added in v0.16.0
IsValidIdentifier is true if the string could be a valid identifier.
func Parse ¶
Parse parses a slice of tokens into a parse tree. Any fodder after the final token is returned as well.
func SnippetToRawAST ¶
func SnippetToRawAST(diagnosticFilename ast.DiagnosticFileName, importedFilename, snippet string) (ast.Node, ast.Fodder, error)
SnippetToRawAST converts a Jsonnet code snippet to an AST (without any transformations). Any fodder after the final token is returned as well.
func StringEscape ¶ added in v0.16.0
StringEscape does the opposite of StringUnescape
func StringUnescape ¶ added in v0.16.0
func StringUnescape(loc *ast.LocationRange, s string) (string, error)
StringUnescape compiles out the escape codes in the string