ast

package
v0.0.0-...-b738e08 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintTree

func PrintTree(node Node)

func Traverse

func Traverse(node Node, f TraverseFn)

Types

type Access

type Access struct {
	*InternalNode
	Token *tokens.Token
	Left  Node
	Right Node
}

func (*Access) Children

func (n *Access) Children() []Node

func (*Access) GetToken

func (n *Access) GetToken() *tokens.Token

func (*Access) String

func (n *Access) String() string

func (*Access) Walk

func (n *Access) Walk(fn WalkFn)

type Assignment

type Assignment struct {
	*InternalNode
	Token    *tokens.Token
	Operator string
	Left     Node
	Right    Node
}

func (*Assignment) Children

func (n *Assignment) Children() []Node

func (*Assignment) GetToken

func (n *Assignment) GetToken() *tokens.Token

func (*Assignment) String

func (n *Assignment) String() string

func (*Assignment) Walk

func (n *Assignment) Walk(fn WalkFn)

type Block

type Block struct {
	*InternalNode
	Token       *tokens.Token
	Expressions []Node
	Scoped      bool
}

func (*Block) Children

func (n *Block) Children() []Node

func (*Block) GetToken

func (n *Block) GetToken() *tokens.Token

func (*Block) String

func (n *Block) String() string

func (*Block) Walk

func (n *Block) Walk(fn WalkFn)

type Boolean

type Boolean struct {
	*InternalNode
	Token *tokens.Token
	Value bool
}

func (*Boolean) Children

func (n *Boolean) Children() []Node

func (*Boolean) GetToken

func (n *Boolean) GetToken() *tokens.Token

func (*Boolean) String

func (n *Boolean) String() string

func (*Boolean) Walk

func (n *Boolean) Walk(fn WalkFn)

type Break

type Break struct {
	*InternalNode
	Token *tokens.Token
}

func (*Break) Children

func (n *Break) Children() []Node

func (*Break) GetToken

func (n *Break) GetToken() *tokens.Token

func (*Break) String

func (n *Break) String() string

func (*Break) Walk

func (n *Break) Walk(fn WalkFn)

type Call

type Call struct {
	*InternalNode
	Token     *tokens.Token
	Target    Node
	Arguments []Node
}

Represent a function or type call, i.e., any `identifier(<expression>, ...)`

func (*Call) Children

func (n *Call) Children() []Node

func (*Call) GetToken

func (n *Call) GetToken() *tokens.Token

func (*Call) String

func (n *Call) String() string

func (*Call) Walk

func (n *Call) Walk(fn WalkFn)

type Continue

type Continue struct {
	*InternalNode
	Token *tokens.Token
}

func (*Continue) Children

func (n *Continue) Children() []Node

func (*Continue) GetToken

func (n *Continue) GetToken() *tokens.Token

func (*Continue) String

func (n *Continue) String() string

func (*Continue) Walk

func (n *Continue) Walk(fn WalkFn)

type DataDef

type DataDef struct {
	*InternalNode
	Token      *tokens.Token
	Name       string
	Extensions []Node
	Attributes map[string]Node
	Methods    map[string]Node
}

Represent a function definition `fn name() {}`

func (*DataDef) Children

func (n *DataDef) Children() []Node

func (*DataDef) GetToken

func (n *DataDef) GetToken() *tokens.Token

func (*DataDef) String

func (n *DataDef) String() string

func (*DataDef) Walk

func (n *DataDef) Walk(fn WalkFn)

type Dict

type Dict struct {
	*InternalNode
	Token    *tokens.Token
	Elements []Node
}

Represents the dict creation `{a=1, b=2, ...}` Elements are a list of [key, value, key, value, ...] pairs

func (*Dict) Children

func (n *Dict) Children() []Node

func (*Dict) GetToken

func (n *Dict) GetToken() *tokens.Token

func (*Dict) String

func (n *Dict) String() string

func (*Dict) Walk

func (n *Dict) Walk(fn WalkFn)

type For

type For struct {
	*InternalNode
	Token        *tokens.Token
	Conditions   []Node
	InExpression Node
	Expression   Node
}

func (*For) Children

func (n *For) Children() []Node

func (*For) GetToken

func (n *For) GetToken() *tokens.Token

func (*For) String

func (n *For) String() string

func (*For) Walk

func (n *For) Walk(fn WalkFn)

type FunctionDef

type FunctionDef struct {
	*InternalNode
	Token      *tokens.Token
	Name       string
	Parameters []Node
	Body       Node
	Generator  bool
}

Represent a function definition `fn name() {}`

func (*FunctionDef) Children

func (n *FunctionDef) Children() []Node

func (*FunctionDef) GetToken

func (n *FunctionDef) GetToken() *tokens.Token

func (*FunctionDef) String

func (n *FunctionDef) String() string

func (*FunctionDef) Walk

func (n *FunctionDef) Walk(fn WalkFn)

type Identifier

type Identifier struct {
	*InternalNode
	Token *tokens.Token
	Value string
}

func (*Identifier) Children

func (n *Identifier) Children() []Node

func (*Identifier) GetToken

func (n *Identifier) GetToken() *tokens.Token

func (*Identifier) String

func (n *Identifier) String() string

func (*Identifier) Walk

func (n *Identifier) Walk(fn WalkFn)

type If

type If struct {
	*InternalNode
	Token           *tokens.Token
	Conditions      []Node
	TrueExpression  Node
	FalseExpression Node
}

func (*If) Children

func (n *If) Children() []Node

func (*If) GetToken

func (n *If) GetToken() *tokens.Token

func (*If) String

func (n *If) String() string

func (*If) Walk

func (n *If) Walk(fn WalkFn)

type Index

type Index struct {
	*InternalNode
	Token  *tokens.Token
	Target Node
	Index  Node
}

Represents access like `a[0]` and `a[a, b]`

func (*Index) Children

func (n *Index) Children() []Node

func (*Index) GetToken

func (n *Index) GetToken() *tokens.Token

func (*Index) String

func (n *Index) String() string

func (*Index) Walk

func (n *Index) Walk(fn WalkFn)

type InfixOperator

type InfixOperator struct {
	*InternalNode
	Token    *tokens.Token
	Operator string
	Left     Node
	Right    Node
}

func (*InfixOperator) Children

func (n *InfixOperator) Children() []Node

func (*InfixOperator) GetToken

func (n *InfixOperator) GetToken() *tokens.Token

func (*InfixOperator) String

func (n *InfixOperator) String() string

func (*InfixOperator) Walk

func (n *InfixOperator) Walk(fn WalkFn)

type Instantiate

type Instantiate struct {
	*InternalNode
	Token    *tokens.Token
	Target   Node
	Elements []Node
}

Represents an instantiation of a type. `CustomType { x=2 }`

func (*Instantiate) Children

func (n *Instantiate) Children() []Node

func (*Instantiate) GetToken

func (n *Instantiate) GetToken() *tokens.Token

func (*Instantiate) String

func (n *Instantiate) String() string

func (*Instantiate) Walk

func (n *Instantiate) Walk(fn WalkFn)

type InternalNode

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

func (*InternalNode) Parent

func (n *InternalNode) Parent() Node

func (*InternalNode) SetParent

func (n *InternalNode) SetParent(parent Node)

func (*InternalNode) SetSourcePath

func (n *InternalNode) SetSourcePath(path string)

func (*InternalNode) SourcePath

func (n *InternalNode) SourcePath() string

type List

type List struct {
	*InternalNode
	Token    *tokens.Token
	Elements []Node
}

Represents the list creation `[1, 2, ...]`

func (*List) Children

func (n *List) Children() []Node

func (*List) GetToken

func (n *List) GetToken() *tokens.Token

func (*List) String

func (n *List) String() string

func (*List) Walk

func (n *List) Walk(fn WalkFn)

type Match

type Match struct {
	*InternalNode
	Token      *tokens.Token
	Expression Node
	Cases      []Node // [condition, expression, condition, expression, ...]
}

func (*Match) Children

func (n *Match) Children() []Node

func (*Match) GetToken

func (n *Match) GetToken() *tokens.Token

func (*Match) String

func (n *Match) String() string

func (*Match) Walk

func (n *Match) Walk(fn WalkFn)

type Node

type Node interface {
	GetToken() *tokens.Token
	String() string
	Children() []Node
	SetSourcePath(path string)
	SourcePath() string
	SetParent(parent Node)
	Parent() Node
	Walk(fn WalkFn)
}

type Number

type Number struct {
	*InternalNode
	Token *tokens.Token
	Value float64
}

func (*Number) Children

func (n *Number) Children() []Node

func (*Number) GetToken

func (n *Number) GetToken() *tokens.Token

func (*Number) String

func (n *Number) String() string

func (*Number) Walk

func (n *Number) Walk(fn WalkFn)

type Pipe

type Pipe struct {
	*InternalNode
	Token *tokens.Token
	Left  Node
	Right Node
}

func (*Pipe) Children

func (n *Pipe) Children() []Node

func (*Pipe) GetToken

func (n *Pipe) GetToken() *tokens.Token

func (*Pipe) String

func (n *Pipe) String() string

func (*Pipe) Walk

func (n *Pipe) Walk(fn WalkFn)

type PrefixOperator

type PrefixOperator struct {
	*InternalNode
	Token    *tokens.Token
	Operator string
	Right    Node
}

func (*PrefixOperator) Children

func (n *PrefixOperator) Children() []Node

func (*PrefixOperator) GetToken

func (n *PrefixOperator) GetToken() *tokens.Token

func (*PrefixOperator) String

func (n *PrefixOperator) String() string

func (*PrefixOperator) Walk

func (n *PrefixOperator) Walk(fn WalkFn)

type Raise

type Raise struct {
	*InternalNode
	Token      *tokens.Token
	Expression Node
}

func (*Raise) Children

func (n *Raise) Children() []Node

func (*Raise) GetToken

func (n *Raise) GetToken() *tokens.Token

func (*Raise) String

func (n *Raise) String() string

func (*Raise) Walk

func (n *Raise) Walk(fn WalkFn)

type Return

type Return struct {
	*InternalNode
	Token      *tokens.Token
	Expression Node
}

func (*Return) Children

func (n *Return) Children() []Node

func (*Return) GetToken

func (n *Return) GetToken() *tokens.Token

func (*Return) String

func (n *Return) String() string

func (*Return) Walk

func (n *Return) Walk(fn WalkFn)

type Spread

type Spread struct {
	*InternalNode
	Token  *tokens.Token
	Target Node
	In     bool
}

func (*Spread) Children

func (u *Spread) Children() []Node

func (*Spread) GetToken

func (u *Spread) GetToken() *tokens.Token

func (*Spread) String

func (u *Spread) String() string

func (*Spread) Walk

func (n *Spread) Walk(fn WalkFn)

type String

type String struct {
	*InternalNode
	Token *tokens.Token
	Value string
}

func (*String) Children

func (n *String) Children() []Node

func (*String) GetToken

func (n *String) GetToken() *tokens.Token

func (*String) String

func (n *String) String() string

func (*String) Walk

func (n *String) Walk(fn WalkFn)

type TraverseFn

type TraverseFn func(depth int, node Node)

type Tuple

type Tuple struct {
	*InternalNode
	Token    *tokens.Token
	Elements []Node
}

func (*Tuple) Children

func (n *Tuple) Children() []Node

func (*Tuple) GetToken

func (n *Tuple) GetToken() *tokens.Token

func (*Tuple) String

func (n *Tuple) String() string

func (*Tuple) Walk

func (n *Tuple) Walk(fn WalkFn)

type Unwrap

type Unwrap struct {
	*InternalNode
	Token  *tokens.Token
	Target Node
}

func (*Unwrap) Children

func (u *Unwrap) Children() []Node

func (*Unwrap) GetToken

func (u *Unwrap) GetToken() *tokens.Token

func (*Unwrap) String

func (u *Unwrap) String() string

func (*Unwrap) Walk

func (n *Unwrap) Walk(fn WalkFn)

type WalkFn

type WalkFn func(Node) Node

type With

type With struct {
	*InternalNode
	Token      *tokens.Token
	Condition  Node
	Expression Node
}

func (*With) Children

func (n *With) Children() []Node

func (*With) GetToken

func (n *With) GetToken() *tokens.Token

func (*With) String

func (n *With) String() string

func (*With) Walk

func (n *With) Walk(fn WalkFn)

type Wrap

type Wrap struct {
	*InternalNode
	Token  *tokens.Token
	Target Node
}

func (*Wrap) Children

func (u *Wrap) Children() []Node

func (*Wrap) GetToken

func (u *Wrap) GetToken() *tokens.Token

func (*Wrap) String

func (u *Wrap) String() string

func (*Wrap) Walk

func (n *Wrap) Walk(fn WalkFn)

type Yield

type Yield struct {
	*InternalNode
	Token      *tokens.Token
	Expression Node
	Break      bool
}

func (*Yield) Children

func (n *Yield) Children() []Node

func (*Yield) GetToken

func (n *Yield) GetToken() *tokens.Token

func (*Yield) String

func (n *Yield) String() string

func (*Yield) Walk

func (n *Yield) Walk(fn WalkFn)

Jump to

Keyboard shortcuts

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