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 LiteralField
- type LiteralFieldSet
- func (set LiteralFieldSet) Add(i LiteralField) bool
- func (set LiteralFieldSet) Cardinality() int
- func (set *LiteralFieldSet) Clear()
- func (set LiteralFieldSet) Clone() LiteralFieldSet
- func (set LiteralFieldSet) Contains(i LiteralField) bool
- func (set LiteralFieldSet) ContainsAll(i ...LiteralField) bool
- func (set LiteralFieldSet) Difference(other LiteralFieldSet) LiteralFieldSet
- func (set LiteralFieldSet) Equal(other LiteralFieldSet) bool
- func (set LiteralFieldSet) Intersect(other LiteralFieldSet) LiteralFieldSet
- func (set LiteralFieldSet) IsSubset(other LiteralFieldSet) bool
- func (set LiteralFieldSet) IsSuperset(other LiteralFieldSet) bool
- func (set LiteralFieldSet) Iter() <-chan LiteralField
- func (set LiteralFieldSet) Remove(i LiteralField)
- func (set LiteralFieldSet) SymmetricDifference(other LiteralFieldSet) LiteralFieldSet
- func (set LiteralFieldSet) ToSlice() []LiteralField
- func (set LiteralFieldSet) Union(other LiteralFieldSet) LiteralFieldSet
- 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
Types ¶
type LiteralField ¶
type LiteralField string
A LiteralField is a field of an object or object comprehension. +gen set
type LiteralFieldSet ¶
type LiteralFieldSet map[LiteralField]struct{}
LiteralFieldSet is the primary type that represents a set
func NewLiteralFieldSet ¶
func NewLiteralFieldSet(a ...LiteralField) LiteralFieldSet
NewLiteralFieldSet creates and returns a reference to an empty set.
func (LiteralFieldSet) Add ¶
func (set LiteralFieldSet) Add(i LiteralField) bool
Add adds an item to the current set if it doesn't already exist in the set.
func (LiteralFieldSet) Cardinality ¶
func (set LiteralFieldSet) Cardinality() int
Cardinality returns how many items are currently in the set.
func (*LiteralFieldSet) Clear ¶
func (set *LiteralFieldSet) Clear()
Clear clears the entire set to be the empty set.
func (LiteralFieldSet) Clone ¶
func (set LiteralFieldSet) Clone() LiteralFieldSet
Clone returns a clone of the set. Does NOT clone the underlying elements.
func (LiteralFieldSet) Contains ¶
func (set LiteralFieldSet) Contains(i LiteralField) bool
Contains determines if a given item is already in the set.
func (LiteralFieldSet) ContainsAll ¶
func (set LiteralFieldSet) ContainsAll(i ...LiteralField) bool
ContainsAll determines if the given items are all in the set
func (LiteralFieldSet) Difference ¶
func (set LiteralFieldSet) Difference(other LiteralFieldSet) LiteralFieldSet
Difference returns a new set with items in the current set but not in the other set
func (LiteralFieldSet) Equal ¶
func (set LiteralFieldSet) Equal(other LiteralFieldSet) bool
Equal determines if two sets are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal.
func (LiteralFieldSet) Intersect ¶
func (set LiteralFieldSet) Intersect(other LiteralFieldSet) LiteralFieldSet
Intersect returns a new set with items that exist only in both sets.
func (LiteralFieldSet) IsSubset ¶
func (set LiteralFieldSet) IsSubset(other LiteralFieldSet) bool
IsSubset determines if every item in the other set is in this set.
func (LiteralFieldSet) IsSuperset ¶
func (set LiteralFieldSet) IsSuperset(other LiteralFieldSet) bool
IsSuperset determines if every item of this set is in the other set.
func (LiteralFieldSet) Iter ¶
func (set LiteralFieldSet) Iter() <-chan LiteralField
Iter returns a channel of type LiteralField that you can range over.
func (LiteralFieldSet) Remove ¶
func (set LiteralFieldSet) Remove(i LiteralField)
Remove allows the removal of a single item in the set.
func (LiteralFieldSet) SymmetricDifference ¶
func (set LiteralFieldSet) SymmetricDifference(other LiteralFieldSet) LiteralFieldSet
SymmetricDifference returns a new set with items in the current set or the other set but not in both.
func (LiteralFieldSet) ToSlice ¶
func (set LiteralFieldSet) ToSlice() []LiteralField
ToSlice returns the elements of the current set as a slice
func (LiteralFieldSet) Union ¶
func (set LiteralFieldSet) Union(other LiteralFieldSet) LiteralFieldSet
Union returns a new set with all items in both sets.