Documentation
¶
Index ¶
- func Dump(node Node) string
- func Patch(node *Node, newNode Node)
- func Walk(node *Node, v Visitor)
- type ArrayNode
- type BinaryNode
- type BoolNode
- type BuiltinNode
- type CallNode
- type ChainNode
- type ClosureNode
- type ConditionalNode
- type ConstantNode
- type FloatNode
- type IdentifierNode
- type IntegerNode
- type MapNode
- type MemberNode
- type NilNode
- type Node
- type PairNode
- type PointerNode
- type SliceNode
- type StringNode
- type UnaryNode
- type VariableDeclaratorNode
- type Visitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArrayNode ¶
type ArrayNode struct {
Nodes []Node // Nodes of the array.
// contains filtered or unexported fields
}
ArrayNode represents an array.
func (*ArrayNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
type BinaryNode ¶
type BinaryNode struct {
Operator string // Operator of the binary operator. Like "+" in "foo + bar" or "matches" in "foo matches bar".
Left Node // Left node of the binary operator.
Right Node // Right node of the binary operator.
// contains filtered or unexported fields
}
BinaryNode represents a binary operator.
func (*BinaryNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
func (*BinaryNode) String ¶
func (n *BinaryNode) String() string
type BoolNode ¶
type BoolNode struct {
Value bool // Value of the boolean.
// contains filtered or unexported fields
}
BoolNode represents a boolean.
func (*BoolNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
type BuiltinNode ¶
type BuiltinNode struct {
Name string // Name of the builtin function. Like "len" in "len(foo)".
Arguments []Node // Arguments of the builtin function.
Throws bool // If true then accessing a field or array index can throw an error. Used by optimizer.
Map Node // Used by optimizer to fold filter() and map() builtins.
// contains filtered or unexported fields
}
BuiltinNode represents a builtin function call.
func (*BuiltinNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
func (*BuiltinNode) String ¶
func (n *BuiltinNode) String() string
type CallNode ¶
type CallNode struct {
Callee Node // Node of the call. Like "foo" in "foo()".
Arguments []Node // Arguments of the call.
// contains filtered or unexported fields
}
CallNode represents a function or a method call.
func (*CallNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
type ChainNode ¶
type ChainNode struct {
Node Node // Node of the chain.
// contains filtered or unexported fields
}
ChainNode represents an optional chaining group. A few MemberNode nodes can be chained together, and will be wrapped in a ChainNode. Example:
foo.bar?.baz?.qux
The whole chain will be wrapped in a ChainNode.
func (*ChainNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
type ClosureNode ¶
type ClosureNode struct {
Node Node // Node of the predicate body.
// contains filtered or unexported fields
}
ClosureNode represents a predicate. Example:
filter(foo, .bar == 1)
The predicate is ".bar == 1".
func (*ClosureNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
func (*ClosureNode) String ¶
func (n *ClosureNode) String() string
type ConditionalNode ¶
type ConditionalNode struct {
Cond Node // Condition of the ternary operator. Like "foo" in "foo ? bar : baz".
Exp1 Node // Expression 1 of the ternary operator. Like "bar" in "foo ? bar : baz".
Exp2 Node // Expression 2 of the ternary operator. Like "baz" in "foo ? bar : baz".
// contains filtered or unexported fields
}
ConditionalNode represents a ternary operator.
func (*ConditionalNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
func (*ConditionalNode) String ¶
func (n *ConditionalNode) String() string
type ConstantNode ¶
type ConstantNode struct {
Value any // Value of the constant.
// contains filtered or unexported fields
}
ConstantNode represents a constant. Constants are predefined values like nil, true, false, array, map, etc. The parser.Parse will never generate ConstantNode, it is only generated by the optimizer.
func (*ConstantNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
func (*ConstantNode) String ¶
func (n *ConstantNode) String() string
type FloatNode ¶
type FloatNode struct {
Value float64 // Value of the float.
// contains filtered or unexported fields
}
FloatNode represents a float.
func (*FloatNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
type IdentifierNode ¶
type IdentifierNode struct {
Value string // Name of the identifier. Like "foo" in "foo.bar".
// contains filtered or unexported fields
}
IdentifierNode represents an identifier.
func (*IdentifierNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
func (*IdentifierNode) String ¶
func (n *IdentifierNode) String() string
type IntegerNode ¶
type IntegerNode struct {
Value int // Value of the integer.
// contains filtered or unexported fields
}
IntegerNode represents an integer.
func (*IntegerNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
func (*IntegerNode) String ¶
func (n *IntegerNode) String() string
type MapNode ¶
type MapNode struct {
Pairs []Node // PairNode nodes.
// contains filtered or unexported fields
}
MapNode represents a map.
func (*MapNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
type MemberNode ¶
type MemberNode struct {
Node Node // Node of the member access. Like "foo" in "foo.bar".
Property Node // Property of the member access. For property access it is a StringNode.
Optional bool // If true then the member access is optional. Like "foo?.bar".
Method bool
// contains filtered or unexported fields
}
MemberNode represents a member access. It can be a field access, a method call, or an array element access. Example:
foo.bar or foo["bar"] foo.bar() array[0]
func (*MemberNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
func (*MemberNode) String ¶
func (n *MemberNode) String() string
type NilNode ¶
type NilNode struct {
// contains filtered or unexported fields
}
NilNode represents nil.
func (*NilNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
type Node ¶
type Node interface {
Location() file.Location
SetLocation(file.Location)
Type() reflect.Type
SetType(reflect.Type)
String() string
}
Node represents items of abstract syntax tree.
type PairNode ¶
type PairNode struct {
Key Node // Key of the pair.
Value Node // Value of the pair.
// contains filtered or unexported fields
}
PairNode represents a key-value pair of a map.
func (*PairNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
type PointerNode ¶
type PointerNode struct {
Name string // Name of the pointer. Like "index" in "#index".
// contains filtered or unexported fields
}
PointerNode represents a pointer to a current value in predicate.
func (*PointerNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
func (*PointerNode) String ¶
func (n *PointerNode) String() string
type SliceNode ¶
type SliceNode struct {
Node Node // Node of the slice. Like "array" in "array[1:4]".
From Node // From an index of the array. Like "1" in "array[1:4]".
To Node // To an index of the array. Like "4" in "array[1:4]".
// contains filtered or unexported fields
}
SliceNode represents access to a slice of an array. Example:
array[1:4]
func (*SliceNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
type StringNode ¶
type StringNode struct {
Value string // Value of the string.
// contains filtered or unexported fields
}
StringNode represents a string.
func (*StringNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
func (*StringNode) String ¶
func (n *StringNode) String() string
type UnaryNode ¶
type UnaryNode struct {
Operator string // Operator of the unary operator. Like "!" in "!foo" or "not" in "not foo".
Node Node // Node of the unary operator. Like "foo" in "!foo".
// contains filtered or unexported fields
}
UnaryNode represents a unary operator.
func (*UnaryNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
type VariableDeclaratorNode ¶
type VariableDeclaratorNode struct {
Name string // Name of the variable. Like "foo" in "let foo = 1; foo + 1".
Value Node // Value of the variable. Like "1" in "let foo = 1; foo + 1".
Expr Node // Expression of the variable. Like "foo + 1" in "let foo = 1; foo + 1".
// contains filtered or unexported fields
}
VariableDeclaratorNode represents a variable declaration.
func (*VariableDeclaratorNode) Location ¶
Location returns the location of the node in the source code.
func (*VariableDeclaratorNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
func (*VariableDeclaratorNode) String ¶
func (n *VariableDeclaratorNode) String() string