ast

package
v1.15.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dump added in v1.5.0

func Dump(node Node) string

func Patch added in v1.7.0

func Patch(node *Node, newNode Node)

func Walk

func Walk(node *Node, v Visitor)

Types

type ArrayNode

type ArrayNode struct {
	Nodes []Node
	// contains filtered or unexported fields
}

func (*ArrayNode) Location added in v1.6.0

func (n *ArrayNode) Location() file.Location

func (*ArrayNode) SetLocation

func (n *ArrayNode) SetLocation(loc file.Location)

func (*ArrayNode) SetType

func (n *ArrayNode) SetType(t reflect.Type)

func (*ArrayNode) String added in v1.14.1

func (n *ArrayNode) String() string

func (*ArrayNode) Type added in v1.6.0

func (n *ArrayNode) Type() reflect.Type

type BinaryNode

type BinaryNode struct {
	Regexp   *regexp.Regexp
	Operator string
	Left     Node
	Right    Node
	// contains filtered or unexported fields
}

func (*BinaryNode) Location added in v1.6.0

func (n *BinaryNode) Location() file.Location

func (*BinaryNode) SetLocation

func (n *BinaryNode) SetLocation(loc file.Location)

func (*BinaryNode) SetType

func (n *BinaryNode) SetType(t reflect.Type)

func (*BinaryNode) String added in v1.14.1

func (n *BinaryNode) String() string

func (*BinaryNode) Type added in v1.6.0

func (n *BinaryNode) Type() reflect.Type

type BoolNode

type BoolNode struct {
	Value bool
	// contains filtered or unexported fields
}

func (*BoolNode) Location added in v1.6.0

func (n *BoolNode) Location() file.Location

func (*BoolNode) SetLocation

func (n *BoolNode) SetLocation(loc file.Location)

func (*BoolNode) SetType

func (n *BoolNode) SetType(t reflect.Type)

func (*BoolNode) String added in v1.14.1

func (n *BoolNode) String() string

func (*BoolNode) Type added in v1.6.0

func (n *BoolNode) Type() reflect.Type

type BuiltinNode

type BuiltinNode struct {
	Name      string
	Arguments []Node
	Throws    bool
	Map       Node
	// contains filtered or unexported fields
}

func (*BuiltinNode) Location added in v1.6.0

func (n *BuiltinNode) Location() file.Location

func (*BuiltinNode) SetLocation

func (n *BuiltinNode) SetLocation(loc file.Location)

func (*BuiltinNode) SetType

func (n *BuiltinNode) SetType(t reflect.Type)

func (*BuiltinNode) String added in v1.14.1

func (n *BuiltinNode) String() string

func (*BuiltinNode) Type added in v1.6.0

func (n *BuiltinNode) Type() reflect.Type

type CallNode added in v1.10.0

type CallNode struct {
	Callee    Node
	Arguments []Node
	Typed     int
	Fast      bool
	Func      *Function
	// contains filtered or unexported fields
}

func (*CallNode) Location added in v1.10.0

func (n *CallNode) Location() file.Location

func (*CallNode) SetLocation added in v1.10.0

func (n *CallNode) SetLocation(loc file.Location)

func (*CallNode) SetType added in v1.10.0

func (n *CallNode) SetType(t reflect.Type)

func (*CallNode) String added in v1.14.1

func (n *CallNode) String() string

func (*CallNode) Type added in v1.10.0

func (n *CallNode) Type() reflect.Type

type ChainNode added in v1.10.0

type ChainNode struct {
	Node Node
	// contains filtered or unexported fields
}

func (*ChainNode) Location added in v1.10.0

func (n *ChainNode) Location() file.Location

func (*ChainNode) SetLocation added in v1.10.0

func (n *ChainNode) SetLocation(loc file.Location)

func (*ChainNode) SetType added in v1.10.0

func (n *ChainNode) SetType(t reflect.Type)

func (*ChainNode) String added in v1.14.1

func (n *ChainNode) String() string

func (*ChainNode) Type added in v1.10.0

func (n *ChainNode) Type() reflect.Type

type ClosureNode

type ClosureNode struct {
	Node Node
	// contains filtered or unexported fields
}

func (*ClosureNode) Location added in v1.6.0

func (n *ClosureNode) Location() file.Location

func (*ClosureNode) SetLocation

func (n *ClosureNode) SetLocation(loc file.Location)

func (*ClosureNode) SetType

func (n *ClosureNode) SetType(t reflect.Type)

func (*ClosureNode) String added in v1.14.1

func (n *ClosureNode) String() string

func (*ClosureNode) Type added in v1.6.0

func (n *ClosureNode) Type() reflect.Type

type ConditionalNode

type ConditionalNode struct {
	Cond Node
	Exp1 Node
	Exp2 Node
	// contains filtered or unexported fields
}

func (*ConditionalNode) Location added in v1.6.0

func (n *ConditionalNode) Location() file.Location

func (*ConditionalNode) SetLocation

func (n *ConditionalNode) SetLocation(loc file.Location)

func (*ConditionalNode) SetType

func (n *ConditionalNode) SetType(t reflect.Type)

func (*ConditionalNode) String added in v1.14.1

func (n *ConditionalNode) String() string

func (*ConditionalNode) Type added in v1.6.0

func (n *ConditionalNode) Type() reflect.Type

type ConstantNode

type ConstantNode struct {
	Value any
	// contains filtered or unexported fields
}

func (*ConstantNode) Location added in v1.6.0

func (n *ConstantNode) Location() file.Location

func (*ConstantNode) SetLocation

func (n *ConstantNode) SetLocation(loc file.Location)

func (*ConstantNode) SetType

func (n *ConstantNode) SetType(t reflect.Type)

func (*ConstantNode) String added in v1.14.1

func (n *ConstantNode) String() string

func (*ConstantNode) Type added in v1.6.0

func (n *ConstantNode) Type() reflect.Type

type FloatNode

type FloatNode struct {
	Value float64
	// contains filtered or unexported fields
}

func (*FloatNode) Location added in v1.6.0

func (n *FloatNode) Location() file.Location

func (*FloatNode) SetLocation

func (n *FloatNode) SetLocation(loc file.Location)

func (*FloatNode) SetType

func (n *FloatNode) SetType(t reflect.Type)

func (*FloatNode) String added in v1.14.1

func (n *FloatNode) String() string

func (*FloatNode) Type added in v1.6.0

func (n *FloatNode) Type() reflect.Type

type Function added in v1.15.0

type Function struct {
	Name      string
	Func      func(args ...any) (any, error)
	Fast      func(arg any) any
	Types     []reflect.Type
	Validate  func(args []reflect.Type) (reflect.Type, error)
	Predicate bool
}

type IdentifierNode

type IdentifierNode struct {
	Value       string
	FieldIndex  []int
	Method      bool // true if method, false if field
	MethodIndex int  // index of method, set only if Method is true
	// contains filtered or unexported fields
}

func (*IdentifierNode) Location added in v1.6.0

func (n *IdentifierNode) Location() file.Location

func (*IdentifierNode) SetFieldIndex added in v1.15.4

func (n *IdentifierNode) SetFieldIndex(field []int)

func (*IdentifierNode) SetLocation

func (n *IdentifierNode) SetLocation(loc file.Location)

func (*IdentifierNode) SetMethodIndex added in v1.15.4

func (n *IdentifierNode) SetMethodIndex(methodIndex int)

func (*IdentifierNode) SetType

func (n *IdentifierNode) SetType(t reflect.Type)

func (*IdentifierNode) String added in v1.14.1

func (n *IdentifierNode) String() string

func (*IdentifierNode) Type added in v1.6.0

func (n *IdentifierNode) Type() reflect.Type

type IntegerNode

type IntegerNode struct {
	Value int
	// contains filtered or unexported fields
}

func (*IntegerNode) Location added in v1.6.0

func (n *IntegerNode) Location() file.Location

func (*IntegerNode) SetLocation

func (n *IntegerNode) SetLocation(loc file.Location)

func (*IntegerNode) SetType

func (n *IntegerNode) SetType(t reflect.Type)

func (*IntegerNode) String added in v1.14.1

func (n *IntegerNode) String() string

func (*IntegerNode) Type added in v1.6.0

func (n *IntegerNode) Type() reflect.Type

type MapNode

type MapNode struct {
	Pairs []Node
	// contains filtered or unexported fields
}

func (*MapNode) Location added in v1.6.0

func (n *MapNode) Location() file.Location

func (*MapNode) SetLocation

func (n *MapNode) SetLocation(loc file.Location)

func (*MapNode) SetType

func (n *MapNode) SetType(t reflect.Type)

func (*MapNode) String added in v1.14.1

func (n *MapNode) String() string

func (*MapNode) Type added in v1.6.0

func (n *MapNode) Type() reflect.Type

type MemberNode added in v1.10.0

type MemberNode struct {
	Node       Node
	Property   Node
	Name       string // Name of the filed or method. Used for error reporting.
	Optional   bool
	FieldIndex []int

	// TODO: Combine Method and MethodIndex into a single MethodIndex field of &int type.
	Method      bool
	MethodIndex int
	// contains filtered or unexported fields
}

func (*MemberNode) Location added in v1.10.0

func (n *MemberNode) Location() file.Location

func (*MemberNode) SetFieldIndex added in v1.15.4

func (n *MemberNode) SetFieldIndex(field []int)

func (*MemberNode) SetLocation added in v1.10.0

func (n *MemberNode) SetLocation(loc file.Location)

func (*MemberNode) SetMethodIndex added in v1.15.4

func (n *MemberNode) SetMethodIndex(methodIndex int)

func (*MemberNode) SetType added in v1.10.0

func (n *MemberNode) SetType(t reflect.Type)

func (*MemberNode) String added in v1.14.1

func (n *MemberNode) String() string

func (*MemberNode) Type added in v1.10.0

func (n *MemberNode) Type() reflect.Type

type NilNode

type NilNode struct {
	// contains filtered or unexported fields
}

func (*NilNode) Location added in v1.6.0

func (n *NilNode) Location() file.Location

func (*NilNode) SetLocation

func (n *NilNode) SetLocation(loc file.Location)

func (*NilNode) SetType

func (n *NilNode) SetType(t reflect.Type)

func (*NilNode) String added in v1.14.1

func (n *NilNode) String() string

func (*NilNode) Type added in v1.6.0

func (n *NilNode) Type() reflect.Type

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
	Value Node
	// contains filtered or unexported fields
}

func (*PairNode) Location added in v1.6.0

func (n *PairNode) Location() file.Location

func (*PairNode) SetLocation

func (n *PairNode) SetLocation(loc file.Location)

func (*PairNode) SetType

func (n *PairNode) SetType(t reflect.Type)

func (*PairNode) String added in v1.14.1

func (n *PairNode) String() string

func (*PairNode) Type added in v1.6.0

func (n *PairNode) Type() reflect.Type

type PointerNode

type PointerNode struct {
	Name string
	// contains filtered or unexported fields
}

func (*PointerNode) Location added in v1.6.0

func (n *PointerNode) Location() file.Location

func (*PointerNode) SetLocation

func (n *PointerNode) SetLocation(loc file.Location)

func (*PointerNode) SetType

func (n *PointerNode) SetType(t reflect.Type)

func (*PointerNode) String added in v1.14.1

func (n *PointerNode) String() string

func (*PointerNode) Type added in v1.6.0

func (n *PointerNode) Type() reflect.Type

type SliceNode

type SliceNode struct {
	Node Node
	From Node
	To   Node
	// contains filtered or unexported fields
}

func (*SliceNode) Location added in v1.6.0

func (n *SliceNode) Location() file.Location

func (*SliceNode) SetLocation

func (n *SliceNode) SetLocation(loc file.Location)

func (*SliceNode) SetType

func (n *SliceNode) SetType(t reflect.Type)

func (*SliceNode) String added in v1.14.1

func (n *SliceNode) String() string

func (*SliceNode) Type added in v1.6.0

func (n *SliceNode) Type() reflect.Type

type StringNode

type StringNode struct {
	Value string
	// contains filtered or unexported fields
}

func (*StringNode) Location added in v1.6.0

func (n *StringNode) Location() file.Location

func (*StringNode) SetLocation

func (n *StringNode) SetLocation(loc file.Location)

func (*StringNode) SetType

func (n *StringNode) SetType(t reflect.Type)

func (*StringNode) String added in v1.14.1

func (n *StringNode) String() string

func (*StringNode) Type added in v1.6.0

func (n *StringNode) Type() reflect.Type

type UnaryNode

type UnaryNode struct {
	Operator string
	Node     Node
	// contains filtered or unexported fields
}

func (*UnaryNode) Location added in v1.6.0

func (n *UnaryNode) Location() file.Location

func (*UnaryNode) SetLocation

func (n *UnaryNode) SetLocation(loc file.Location)

func (*UnaryNode) SetType

func (n *UnaryNode) SetType(t reflect.Type)

func (*UnaryNode) String added in v1.14.1

func (n *UnaryNode) String() string

func (*UnaryNode) Type added in v1.6.0

func (n *UnaryNode) Type() reflect.Type

type VariableDeclaratorNode added in v1.15.0

type VariableDeclaratorNode struct {
	Name  string
	Value Node
	Expr  Node
	// contains filtered or unexported fields
}

func (*VariableDeclaratorNode) Location added in v1.15.0

func (n *VariableDeclaratorNode) Location() file.Location

func (*VariableDeclaratorNode) SetLocation added in v1.15.0

func (n *VariableDeclaratorNode) SetLocation(loc file.Location)

func (*VariableDeclaratorNode) SetType added in v1.15.0

func (n *VariableDeclaratorNode) SetType(t reflect.Type)

func (*VariableDeclaratorNode) String added in v1.15.0

func (n *VariableDeclaratorNode) String() string

func (*VariableDeclaratorNode) Type added in v1.15.0

func (n *VariableDeclaratorNode) Type() reflect.Type

type Visitor

type Visitor interface {
	Visit(node *Node)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL