node

package
v0.0.0-...-baef74e Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxIterations = 1000

Variables

This section is empty.

Functions

This section is empty.

Types

type Appender

type Appender interface {
	Node
	Append(Node)
}

type AssignmentNode

type AssignmentNode struct {
	BaseNode
	Assignee   *LocalVarNode
	Expression Node
}

func NewAssignmentNode

func NewAssignmentNode(pos int, symbol string) *AssignmentNode

func (*AssignmentNode) Copy

func (n *AssignmentNode) Copy() Node

func (*AssignmentNode) Visit

func (n *AssignmentNode) Visit(c chan Node)

type BaseNode

type BaseNode struct {
	NodeType // String() is delegated here
	// contains filtered or unexported fields
}

BaseNode is the most basic node with no extra data attached to it

func NewNoopNode

func NewNoopNode() *BaseNode

NewNoopNode returns a op that does nothing

func (*BaseNode) Copy

func (n *BaseNode) Copy() Node

func (*BaseNode) Pos

func (n *BaseNode) Pos() int

Pos returns the position of this node in the document

func (*BaseNode) Visit

func (n *BaseNode) Visit(c chan Node)

type BinaryNode

type BinaryNode struct {
	BaseNode
	Left  Node
	Right Node
}

func NewDivNode

func NewDivNode(pos int) *BinaryNode

func NewEqualsNode

func NewEqualsNode(pos int) *BinaryNode

func NewFetchArrayElementNode

func NewFetchArrayElementNode(pos int) *BinaryNode

func NewGTNode

func NewGTNode(pos int) *BinaryNode

func NewLTNode

func NewLTNode(pos int) *BinaryNode

func NewMinusNode

func NewMinusNode(pos int) *BinaryNode

func NewMulNode

func NewMulNode(pos int) *BinaryNode

func NewNotEqualsNode

func NewNotEqualsNode(pos int) *BinaryNode

func NewPlusNode

func NewPlusNode(pos int) *BinaryNode

func NewRangeNode

func NewRangeNode(pos int, start, end Node) *BinaryNode

func (*BinaryNode) Copy

func (n *BinaryNode) Copy() Node

func (*BinaryNode) Visit

func (n *BinaryNode) Visit(c chan Node)

type ElseNode

type ElseNode struct {
	*ListNode
	IfNode Node
}

func NewElseNode

func NewElseNode(pos int) *ElseNode

type FetchFieldNode

type FetchFieldNode struct {
	BaseNode
	Container Node
	FieldName string
}

func NewFetchFieldNode

func NewFetchFieldNode(pos int, container Node, field string) *FetchFieldNode

func (*FetchFieldNode) Copy

func (n *FetchFieldNode) Copy() Node

func (*FetchFieldNode) Visit

func (n *FetchFieldNode) Visit(c chan Node)

type FilterNode

type FilterNode struct {
	*UnaryNode
	Name string
}

func NewFilterNode

func NewFilterNode(pos int, name string, child Node) *FilterNode

func (*FilterNode) Copy

func (n *FilterNode) Copy() Node

func (*FilterNode) Visit

func (n *FilterNode) Visit(c chan Node)

type ForeachNode

type ForeachNode struct {
	*LoopNode
	IndexVarName string
	IndexVarIdx  int
	List         Node
}

func NewForeachNode

func NewForeachNode(pos int, symbol string) *ForeachNode

func (*ForeachNode) Copy

func (n *ForeachNode) Copy() Node

func (*ForeachNode) String

func (n *ForeachNode) String() string

func (*ForeachNode) Visit

func (n *ForeachNode) Visit(c chan Node)

type FunCallNode

type FunCallNode struct {
	BaseNode
	Invocant Node
	Args     *ListNode
}

func NewFunCallNode

func NewFunCallNode(pos int, invocant Node, args *ListNode) *FunCallNode

func (*FunCallNode) Copy

func (n *FunCallNode) Copy() Node

func (*FunCallNode) Visit

func (n *FunCallNode) Visit(c chan Node)

type IfNode

type IfNode struct {
	*ListNode
	BooleanExpression Node
}

func NewIfNode

func NewIfNode(pos int, exp Node) *IfNode

func (*IfNode) Copy

func (n *IfNode) Copy() Node

func (*IfNode) Visit

func (n *IfNode) Visit(c chan Node)

type IncludeNode

type IncludeNode struct {
	BaseNode
	IncludeTarget   Node
	AssignmentNodes []Node
}

func NewIncludeNode

func NewIncludeNode(pos int, include Node) *IncludeNode

func (*IncludeNode) AppendAssignment

func (n *IncludeNode) AppendAssignment(a Node)

func (*IncludeNode) Copy

func (n *IncludeNode) Copy() Node

func (*IncludeNode) Visit

func (n *IncludeNode) Visit(c chan Node)

type ListNode

type ListNode struct {
	BaseNode
	Nodes []Node
}

func NewListNode

func NewListNode(pos int) *ListNode

func NewPrintNode

func NewPrintNode(pos int, arg Node) *ListNode

func NewPrintRawNode

func NewPrintRawNode(pos int) *ListNode

func NewRootNode

func NewRootNode() *ListNode

func (*ListNode) Append

func (l *ListNode) Append(n Node)

func (*ListNode) Copy

func (l *ListNode) Copy() Node

func (*ListNode) Visit

func (l *ListNode) Visit(c chan Node)

type LocalVarNode

type LocalVarNode struct {
	BaseNode
	Name   string
	Offset int
}

func NewLocalVarNode

func NewLocalVarNode(pos int, symbol string, idx int) *LocalVarNode

func (*LocalVarNode) Copy

func (n *LocalVarNode) Copy() Node

func (*LocalVarNode) String

func (n *LocalVarNode) String() string

func (*LocalVarNode) Visit

func (n *LocalVarNode) Visit(c chan Node)

type LoopNode

type LoopNode struct {
	*ListNode         // Body of the loop
	Condition    Node //
	MaxIteration int  // Max number of iterations
}

func NewLoopNode

func NewLoopNode(pos int) *LoopNode

type MacroNode

type MacroNode struct {
	*ListNode
	Name      string
	LocalVar  *LocalVarNode
	Arguments []*LocalVarNode
}

func NewMacroNode

func NewMacroNode(pos int, name string) *MacroNode

func (*MacroNode) AppendArg

func (n *MacroNode) AppendArg(arg *LocalVarNode)

type MethodCallNode

type MethodCallNode struct {
	BaseNode
	Invocant   Node
	MethodName string
	Args       *ListNode
}

func NewMethodCallNode

func NewMethodCallNode(pos int, invocant Node, method string, args *ListNode) *MethodCallNode

func (*MethodCallNode) Copy

func (n *MethodCallNode) Copy() Node

func (*MethodCallNode) Visit

func (n *MethodCallNode) Visit(c chan Node)

type Node

type Node interface {
	Type() NodeType
	Copy() Node
	Pos() int
	Visit(chan Node)
}

Node defines the interface for an AST node

type NodeType

type NodeType int

NodeType is used to distinguish each AST node

const (
	Noop NodeType = iota
	Root
	Text
	Number
	Int
	Float
	If
	Else
	List
	Foreach
	While
	Wrapper
	Include
	Assignment
	LocalVar
	FetchField
	FetchArrayElement
	MethodCall
	FunCall
	Print
	PrintRaw
	FetchSymbol
	Range
	Plus
	Minus
	Mul
	Div
	Equals
	NotEquals
	LT
	GT
	MakeArray
	Group
	Filter
	Macro
	Max
)

func (NodeType) String

func (i NodeType) String() string

func (NodeType) Type

func (n NodeType) Type() NodeType

Type returns the current node type

type NumberNode

type NumberNode struct {
	BaseNode
	Value reflect.Value
}

func NewFloatNode

func NewFloatNode(pos int, v float64) *NumberNode

func NewIntNode

func NewIntNode(pos int, v int64) *NumberNode

func NewNumberNode

func NewNumberNode(pos int, num reflect.Value) *NumberNode

func (*NumberNode) Copy

func (n *NumberNode) Copy() Node

func (*NumberNode) Visit

func (n *NumberNode) Visit(c chan Node)

type TextNode

type TextNode struct {
	BaseNode
	Text []byte
}

func NewFetchSymbolNode

func NewFetchSymbolNode(pos int, symbol string) *TextNode

func NewTextNode

func NewTextNode(pos int, arg string) *TextNode

func (*TextNode) Copy

func (n *TextNode) Copy() Node

func (*TextNode) String

func (n *TextNode) String() string

func (*TextNode) Visit

func (n *TextNode) Visit(c chan Node)

type UnaryNode

type UnaryNode struct {
	BaseNode
	Child Node
}

func NewGroupNode

func NewGroupNode(pos int) *UnaryNode

func NewMakeArrayNode

func NewMakeArrayNode(pos int, child Node) *UnaryNode

func (*UnaryNode) Copy

func (n *UnaryNode) Copy() Node

func (*UnaryNode) Visit

func (n *UnaryNode) Visit(c chan Node)

type WhileNode

type WhileNode struct {
	*LoopNode
}

func NewWhileNode

func NewWhileNode(pos int, n Node) *WhileNode

func (*WhileNode) Copy

func (n *WhileNode) Copy() Node

func (*WhileNode) Visit

func (n *WhileNode) Visit(c chan Node)

type WrapperNode

type WrapperNode struct {
	*ListNode
	WrapperName string
	// XXX need to make this configurable. currently it's only "content"
	// WrapInto string
	AssignmentNodes []Node
}

func NewWrapperNode

func NewWrapperNode(pos int, template string) *WrapperNode

func (*WrapperNode) AppendAssignment

func (n *WrapperNode) AppendAssignment(a Node)

func (*WrapperNode) Copy

func (n *WrapperNode) Copy() Node

func (*WrapperNode) Visit

func (n *WrapperNode) Visit(c chan Node)

Jump to

Keyboard shortcuts

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