Documentation ¶
Index ¶
- func Dump(node Node) string
- func Patch(node *Node, newNode Node)
- func Walk(node *Node, v Visitor)
- type ArrayNode
- func (n *ArrayNode) Location() file.Location
- func (n *ArrayNode) Nature() nature.Nature
- func (n *ArrayNode) SetLocation(loc file.Location)
- func (n *ArrayNode) SetNature(nature nature.Nature)
- func (n *ArrayNode) SetType(t reflect.Type)
- func (n *ArrayNode) String() string
- func (n *ArrayNode) Type() reflect.Type
- type BinaryNode
- func (n *BinaryNode) Location() file.Location
- func (n *BinaryNode) Nature() nature.Nature
- func (n *BinaryNode) SetLocation(loc file.Location)
- func (n *BinaryNode) SetNature(nature nature.Nature)
- func (n *BinaryNode) SetType(t reflect.Type)
- func (n *BinaryNode) String() string
- func (n *BinaryNode) Type() reflect.Type
- type BoolNode
- func (n *BoolNode) Location() file.Location
- func (n *BoolNode) Nature() nature.Nature
- func (n *BoolNode) SetLocation(loc file.Location)
- func (n *BoolNode) SetNature(nature nature.Nature)
- func (n *BoolNode) SetType(t reflect.Type)
- func (n *BoolNode) String() string
- func (n *BoolNode) Type() reflect.Type
- type BuiltinNode
- func (n *BuiltinNode) Location() file.Location
- func (n *BuiltinNode) Nature() nature.Nature
- func (n *BuiltinNode) SetLocation(loc file.Location)
- func (n *BuiltinNode) SetNature(nature nature.Nature)
- func (n *BuiltinNode) SetType(t reflect.Type)
- func (n *BuiltinNode) String() string
- func (n *BuiltinNode) Type() reflect.Type
- type CallNode
- func (n *CallNode) Location() file.Location
- func (n *CallNode) Nature() nature.Nature
- func (n *CallNode) SetLocation(loc file.Location)
- func (n *CallNode) SetNature(nature nature.Nature)
- func (n *CallNode) SetType(t reflect.Type)
- func (n *CallNode) String() string
- func (n *CallNode) Type() reflect.Type
- type ChainNode
- func (n *ChainNode) Location() file.Location
- func (n *ChainNode) Nature() nature.Nature
- func (n *ChainNode) SetLocation(loc file.Location)
- func (n *ChainNode) SetNature(nature nature.Nature)
- func (n *ChainNode) SetType(t reflect.Type)
- func (n *ChainNode) String() string
- func (n *ChainNode) Type() reflect.Type
- type ConditionalNode
- func (n *ConditionalNode) Location() file.Location
- func (n *ConditionalNode) Nature() nature.Nature
- func (n *ConditionalNode) SetLocation(loc file.Location)
- func (n *ConditionalNode) SetNature(nature nature.Nature)
- func (n *ConditionalNode) SetType(t reflect.Type)
- func (n *ConditionalNode) String() string
- func (n *ConditionalNode) Type() reflect.Type
- type ConstantNode
- func (n *ConstantNode) Location() file.Location
- func (n *ConstantNode) Nature() nature.Nature
- func (n *ConstantNode) SetLocation(loc file.Location)
- func (n *ConstantNode) SetNature(nature nature.Nature)
- func (n *ConstantNode) SetType(t reflect.Type)
- func (n *ConstantNode) String() string
- func (n *ConstantNode) Type() reflect.Type
- type FloatNode
- func (n *FloatNode) Location() file.Location
- func (n *FloatNode) Nature() nature.Nature
- func (n *FloatNode) SetLocation(loc file.Location)
- func (n *FloatNode) SetNature(nature nature.Nature)
- func (n *FloatNode) SetType(t reflect.Type)
- func (n *FloatNode) String() string
- func (n *FloatNode) Type() reflect.Type
- type IdentifierNode
- func (n *IdentifierNode) Location() file.Location
- func (n *IdentifierNode) Nature() nature.Nature
- func (n *IdentifierNode) SetLocation(loc file.Location)
- func (n *IdentifierNode) SetNature(nature nature.Nature)
- func (n *IdentifierNode) SetType(t reflect.Type)
- func (n *IdentifierNode) String() string
- func (n *IdentifierNode) Type() reflect.Type
- type IntegerNode
- func (n *IntegerNode) Location() file.Location
- func (n *IntegerNode) Nature() nature.Nature
- func (n *IntegerNode) SetLocation(loc file.Location)
- func (n *IntegerNode) SetNature(nature nature.Nature)
- func (n *IntegerNode) SetType(t reflect.Type)
- func (n *IntegerNode) String() string
- func (n *IntegerNode) Type() reflect.Type
- type MapNode
- type MemberNode
- func (n *MemberNode) Location() file.Location
- func (n *MemberNode) Nature() nature.Nature
- func (n *MemberNode) SetLocation(loc file.Location)
- func (n *MemberNode) SetNature(nature nature.Nature)
- func (n *MemberNode) SetType(t reflect.Type)
- func (n *MemberNode) String() string
- func (n *MemberNode) Type() reflect.Type
- type NilNode
- type Node
- type PairNode
- func (n *PairNode) Location() file.Location
- func (n *PairNode) Nature() nature.Nature
- func (n *PairNode) SetLocation(loc file.Location)
- func (n *PairNode) SetNature(nature nature.Nature)
- func (n *PairNode) SetType(t reflect.Type)
- func (n *PairNode) String() string
- func (n *PairNode) Type() reflect.Type
- type PointerNode
- func (n *PointerNode) Location() file.Location
- func (n *PointerNode) Nature() nature.Nature
- func (n *PointerNode) SetLocation(loc file.Location)
- func (n *PointerNode) SetNature(nature nature.Nature)
- func (n *PointerNode) SetType(t reflect.Type)
- func (n *PointerNode) String() string
- func (n *PointerNode) Type() reflect.Type
- type PredicateNode
- func (n *PredicateNode) Location() file.Location
- func (n *PredicateNode) Nature() nature.Nature
- func (n *PredicateNode) SetLocation(loc file.Location)
- func (n *PredicateNode) SetNature(nature nature.Nature)
- func (n *PredicateNode) SetType(t reflect.Type)
- func (n *PredicateNode) String() string
- func (n *PredicateNode) Type() reflect.Type
- type SliceNode
- func (n *SliceNode) Location() file.Location
- func (n *SliceNode) Nature() nature.Nature
- func (n *SliceNode) SetLocation(loc file.Location)
- func (n *SliceNode) SetNature(nature nature.Nature)
- func (n *SliceNode) SetType(t reflect.Type)
- func (n *SliceNode) String() string
- func (n *SliceNode) Type() reflect.Type
- type StringNode
- func (n *StringNode) Location() file.Location
- func (n *StringNode) Nature() nature.Nature
- func (n *StringNode) SetLocation(loc file.Location)
- func (n *StringNode) SetNature(nature nature.Nature)
- func (n *StringNode) SetType(t reflect.Type)
- func (n *StringNode) String() string
- func (n *StringNode) Type() reflect.Type
- type UnaryNode
- func (n *UnaryNode) Location() file.Location
- func (n *UnaryNode) Nature() nature.Nature
- func (n *UnaryNode) SetLocation(loc file.Location)
- func (n *UnaryNode) SetNature(nature nature.Nature)
- func (n *UnaryNode) SetType(t reflect.Type)
- func (n *UnaryNode) String() string
- func (n *UnaryNode) Type() reflect.Type
- type VariableDeclaratorNode
- func (n *VariableDeclaratorNode) Location() file.Location
- func (n *VariableDeclaratorNode) Nature() nature.Nature
- func (n *VariableDeclaratorNode) SetLocation(loc file.Location)
- func (n *VariableDeclaratorNode) SetNature(nature nature.Nature)
- func (n *VariableDeclaratorNode) SetType(t reflect.Type)
- func (n *VariableDeclaratorNode) String() string
- func (n *VariableDeclaratorNode) Type() reflect.Type
- 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 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) Nature() nature.Nature SetNature(nature.Nature) 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 PredicateNode ¶
type PredicateNode struct { Node Node // Node of the predicate body. // contains filtered or unexported fields }
PredicateNode represents a predicate. Example:
filter(foo, .bar == 1)
The predicate is ".bar == 1".
func (*PredicateNode) SetLocation ¶
SetLocation sets the location of the node in the source code.
func (*PredicateNode) String ¶
func (n *PredicateNode) 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