ast

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UNKNOWN = -1
)

Variables

This section is empty.

Functions

func EvalMain

func EvalMain(bf *OptFunction, en envir.Environment) (interface{}, error)

func FunctionLookup

func FunctionLookup(sym *envir.Symbols, params *ParameterList, body *BlockStmt) int

Types

type ASTLeaf

type ASTLeaf struct {
	Token token.Token
}

func NewASTLeaf

func NewASTLeaf(token token.Token) *ASTLeaf

func (*ASTLeaf) Child

func (leaf *ASTLeaf) Child(i int) (ASTree, error)

func (*ASTLeaf) Children

func (leaf *ASTLeaf) Children() *base.List[ASTree]

func (*ASTLeaf) Eval

func (leaf *ASTLeaf) Eval(env envir.Environment) (interface{}, error)

func (*ASTLeaf) GetString

func (leaf *ASTLeaf) GetString() (string, error)

func (*ASTLeaf) GetToken

func (leaf *ASTLeaf) GetToken() token.Token

func (*ASTLeaf) Location

func (leaf *ASTLeaf) Location() string

func (*ASTLeaf) Lookup

func (leaf *ASTLeaf) Lookup(sym *envir.Symbols)

func (*ASTLeaf) NumChildren

func (leaf *ASTLeaf) NumChildren() int

type ASTList

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

func NewASTList

func NewASTList(l *base.List[ASTree]) *ASTList

func (*ASTList) Child

func (l *ASTList) Child(i int) (ASTree, error)

func (*ASTList) Children

func (l *ASTList) Children() *base.List[ASTree]

func (*ASTList) Eval

func (l *ASTList) Eval(env envir.Environment) (interface{}, error)

func (*ASTList) GetString

func (l *ASTList) GetString() (string, error)

func (*ASTList) Location

func (l *ASTList) Location() string

func (*ASTList) Lookup

func (l *ASTList) Lookup(sym *envir.Symbols)

func (*ASTList) NumChildren

func (l *ASTList) NumChildren() int

type ASTree

type ASTree interface {
	Child(i int) (ASTree, error)
	NumChildren() int
	Children() *base.List[ASTree]
	Location() string
	GetString() (string, error)
	Eval(env envir.Environment) (interface{}, error)
	Lookup(sym *envir.Symbols)
}

func NewPrimaryExpr

func NewPrimaryExpr(l *base.List[ASTree]) ASTree

type Arguments

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

func NewArguments

func NewArguments(l *base.List[ASTree]) *Arguments

func (*Arguments) Child

func (a *Arguments) Child(i int) (ASTree, error)

func (*Arguments) Children

func (a *Arguments) Children() *base.List[ASTree]

func (*Arguments) Eval

func (a *Arguments) Eval(env envir.Environment) (interface{}, error)

func (*Arguments) Eval0

func (a *Arguments) Eval0(en envir.Environment, value interface{}) (interface{}, error)

func (*Arguments) GetString

func (a *Arguments) GetString() (string, error)

func (*Arguments) Location

func (a *Arguments) Location() string

func (*Arguments) Lookup

func (a *Arguments) Lookup(sym *envir.Symbols)

func (*Arguments) NumChildren

func (a *Arguments) NumChildren() int

func (*Arguments) Size

func (a *Arguments) Size() int

type ArrayLiteral

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

func NewArrayLiteral

func NewArrayLiteral(l *base.List[ASTree]) *ArrayLiteral

func (*ArrayLiteral) Child

func (a *ArrayLiteral) Child(i int) (ASTree, error)

func (*ArrayLiteral) Children

func (a *ArrayLiteral) Children() *base.List[ASTree]

func (*ArrayLiteral) Eval

func (a *ArrayLiteral) Eval(env envir.Environment) (interface{}, error)

func (*ArrayLiteral) GetString

func (a *ArrayLiteral) GetString() (string, error)

func (*ArrayLiteral) Location

func (a *ArrayLiteral) Location() string

func (*ArrayLiteral) Lookup

func (a *ArrayLiteral) Lookup(sym *envir.Symbols)

func (*ArrayLiteral) NumChildren

func (a *ArrayLiteral) NumChildren() int

func (*ArrayLiteral) Size

func (a *ArrayLiteral) Size() int

type ArrayRef

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

func NewArrayRef

func NewArrayRef(l *base.List[ASTree]) *ArrayRef

func (*ArrayRef) Child

func (a *ArrayRef) Child(i int) (ASTree, error)

func (*ArrayRef) Children

func (a *ArrayRef) Children() *base.List[ASTree]

func (*ArrayRef) Eval

func (a *ArrayRef) Eval(env envir.Environment) (interface{}, error)

func (*ArrayRef) Eval0

func (a *ArrayRef) Eval0(env envir.Environment, value interface{}) (interface{}, error)

func (*ArrayRef) GetString

func (a *ArrayRef) GetString() (string, error)

func (*ArrayRef) Index

func (a *ArrayRef) Index() (ASTree, error)

func (*ArrayRef) Location

func (a *ArrayRef) Location() string

func (*ArrayRef) Lookup

func (a *ArrayRef) Lookup(sym *envir.Symbols)

func (*ArrayRef) NumChildren

func (a *ArrayRef) NumChildren() int

type BinaryExpr

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

func NewBinaryExpr

func NewBinaryExpr(l *base.List[ASTree]) *BinaryExpr

func (*BinaryExpr) Child

func (b *BinaryExpr) Child(i int) (ASTree, error)

func (*BinaryExpr) Children

func (b *BinaryExpr) Children() *base.List[ASTree]

func (*BinaryExpr) Eval

func (b *BinaryExpr) Eval(env envir.Environment) (interface{}, error)

func (*BinaryExpr) GetString

func (b *BinaryExpr) GetString() (string, error)

func (*BinaryExpr) Location

func (b *BinaryExpr) Location() string

func (*BinaryExpr) Lookup

func (b *BinaryExpr) Lookup(sym *envir.Symbols)

func (*BinaryExpr) NumChildren

func (b *BinaryExpr) NumChildren() int

type BlockStmt

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

func NewBlockStmt

func NewBlockStmt(l *base.List[ASTree]) *BlockStmt

func (*BlockStmt) Child

func (b *BlockStmt) Child(i int) (ASTree, error)

func (*BlockStmt) Children

func (b *BlockStmt) Children() *base.List[ASTree]

func (*BlockStmt) Eval

func (b *BlockStmt) Eval(env envir.Environment) (interface{}, error)

func (*BlockStmt) GetString

func (b *BlockStmt) GetString() (string, error)

func (*BlockStmt) Location

func (b *BlockStmt) Location() string

func (*BlockStmt) Lookup

func (b *BlockStmt) Lookup(sym *envir.Symbols)

func (*BlockStmt) NumChildren

func (b *BlockStmt) NumChildren() int

type BreakSignal

type BreakSignal struct {
	Val bool
}

BreakSignal control break while

type BreakStmt

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

func NewBreakStmt

func NewBreakStmt(l *base.List[ASTree]) *BreakStmt

func (*BreakStmt) Child

func (b *BreakStmt) Child(i int) (ASTree, error)

func (*BreakStmt) Children

func (b *BreakStmt) Children() *base.List[ASTree]

func (*BreakStmt) Eval

func (b *BreakStmt) Eval(env envir.Environment) (interface{}, error)

func (*BreakStmt) GetString

func (b *BreakStmt) GetString() (string, error)

func (*BreakStmt) Location

func (b *BreakStmt) Location() string

func (*BreakStmt) Lookup

func (b *BreakStmt) Lookup(sym *envir.Symbols)

func (*BreakStmt) NumChildren

func (b *BreakStmt) NumChildren() int

type ContinueSignal

type ContinueSignal struct {
	Val bool
}

ContinueSignal control continue while

type ContinueStmt

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

func NewContinueStmt

func NewContinueStmt(l *base.List[ASTree]) *ContinueStmt

func (*ContinueStmt) Child

func (c *ContinueStmt) Child(i int) (ASTree, error)

func (*ContinueStmt) Children

func (c *ContinueStmt) Children() *base.List[ASTree]

func (*ContinueStmt) Eval

func (c *ContinueStmt) Eval(env envir.Environment) (interface{}, error)

func (*ContinueStmt) GetString

func (c *ContinueStmt) GetString() (string, error)

func (*ContinueStmt) Location

func (c *ContinueStmt) Location() string

func (*ContinueStmt) Lookup

func (c *ContinueStmt) Lookup(sym *envir.Symbols)

func (*ContinueStmt) NumChildren

func (c *ContinueStmt) NumChildren() int

type DefStmt

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

func NewDefStmt

func NewDefStmt(l *base.List[ASTree]) *DefStmt

func (*DefStmt) Body

func (d *DefStmt) Body() (*BlockStmt, error)

func (*DefStmt) Child

func (d *DefStmt) Child(i int) (ASTree, error)

func (*DefStmt) Children

func (d *DefStmt) Children() *base.List[ASTree]

func (*DefStmt) Eval

func (d *DefStmt) Eval(en envir.Environment) (interface{}, error)

func (*DefStmt) GetString

func (d *DefStmt) GetString() (string, error)

func (*DefStmt) Location

func (d *DefStmt) Location() string

func (*DefStmt) Lookup

func (d *DefStmt) Lookup(sym *envir.Symbols)

func (*DefStmt) Name

func (d *DefStmt) Name() (string, error)

func (*DefStmt) NumChildren

func (d *DefStmt) NumChildren() int

func (*DefStmt) Parameters

func (d *DefStmt) Parameters() (*ParameterList, error)

type ForStmt

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

func NewForStmt

func NewForStmt(l *base.List[ASTree]) *ForStmt

func (*ForStmt) Child

func (w *ForStmt) Child(i int) (ASTree, error)

func (*ForStmt) Children

func (w *ForStmt) Children() *base.List[ASTree]

func (*ForStmt) Eval

func (w *ForStmt) Eval(en envir.Environment) (interface{}, error)

func (*ForStmt) GetString

func (w *ForStmt) GetString() (string, error)

func (*ForStmt) Location

func (w *ForStmt) Location() string

func (*ForStmt) Lookup

func (w *ForStmt) Lookup(sym *envir.Symbols)

func (*ForStmt) NumChildren

func (w *ForStmt) NumChildren() int

type Function

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

func NewFunction

func NewFunction(parameters *ParameterList,
	body *BlockStmt, en envir.Environment) *Function

func (*Function) Body

func (f *Function) Body() *BlockStmt

func (*Function) Parameters

func (f *Function) Parameters() *ParameterList

type GoStmt

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

func NewGoStmt

func NewGoStmt(l *base.List[ASTree]) *GoStmt

func (*GoStmt) Child

func (g *GoStmt) Child(i int) (ASTree, error)

func (*GoStmt) Children

func (g *GoStmt) Children() *base.List[ASTree]

func (*GoStmt) Eval

func (g *GoStmt) Eval(env envir.Environment) (interface{}, error)

func (*GoStmt) GetString

func (g *GoStmt) GetString() (string, error)

func (*GoStmt) Location

func (g *GoStmt) Location() string

func (*GoStmt) Lookup

func (g *GoStmt) Lookup(sym *envir.Symbols)

func (*GoStmt) NumChildren

func (g *GoStmt) NumChildren() int

type IfStmt

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

func NewIfStmt

func NewIfStmt(l *base.List[ASTree]) *IfStmt

func (*IfStmt) Child

func (is *IfStmt) Child(i int) (ASTree, error)

func (*IfStmt) Children

func (is *IfStmt) Children() *base.List[ASTree]

func (*IfStmt) Condition

func (is *IfStmt) Condition() (ASTree, error)

func (*IfStmt) ElseBlock

func (is *IfStmt) ElseBlock() (ASTree, error)

func (*IfStmt) Eval

func (is *IfStmt) Eval(en envir.Environment) (interface{}, error)

func (*IfStmt) GetString

func (is *IfStmt) GetString() (string, error)

func (*IfStmt) Location

func (is *IfStmt) Location() string

func (*IfStmt) Lookup

func (is *IfStmt) Lookup(sym *envir.Symbols)

func (*IfStmt) NumChildren

func (is *IfStmt) NumChildren() int

func (*IfStmt) ThenBlock

func (is *IfStmt) ThenBlock() (ASTree, error)

type IncludeStmt

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

func NewIncludeStmt

func NewIncludeStmt(l *base.List[ASTree]) *IncludeStmt

func (*IncludeStmt) Child

func (ic *IncludeStmt) Child(i int) (ASTree, error)

func (*IncludeStmt) Children

func (ic *IncludeStmt) Children() *base.List[ASTree]

func (*IncludeStmt) Eval

func (ic *IncludeStmt) Eval(en envir.Environment) (interface{}, error)

func (*IncludeStmt) GetString

func (ic *IncludeStmt) GetString() (string, error)

func (*IncludeStmt) Location

func (ic *IncludeStmt) Location() string

func (*IncludeStmt) Lookup

func (ic *IncludeStmt) Lookup(sym *envir.Symbols)

func (*IncludeStmt) NumChildren

func (ic *IncludeStmt) NumChildren() int

type Name

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

func NewName

func NewName(t token.Token) *Name

func (*Name) Child

func (n *Name) Child(i int) (ASTree, error)

func (*Name) Children

func (n *Name) Children() *base.List[ASTree]

func (*Name) Eval

func (n *Name) Eval(env envir.Environment) (interface{}, error)

func (*Name) EvalForAssign

func (n *Name) EvalForAssign(env envir.Environment, value interface{})

func (*Name) GetString

func (n *Name) GetString() (string, error)

func (*Name) Location

func (n *Name) Location() string

func (*Name) Lookup

func (n *Name) Lookup(sym *envir.Symbols)

func (*Name) LookupForAssign

func (n *Name) LookupForAssign(sym *envir.Symbols)

func (*Name) Name

func (n *Name) Name() (string, error)

func (*Name) NumChildren

func (n *Name) NumChildren() int

func (*Name) Token

func (n *Name) Token() token.Token

type NegativeExpr

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

func NewNegativeExpr

func NewNegativeExpr(l *base.List[ASTree]) *NegativeExpr

func (*NegativeExpr) Child

func (n *NegativeExpr) Child(i int) (ASTree, error)

func (*NegativeExpr) Children

func (n *NegativeExpr) Children() *base.List[ASTree]

func (*NegativeExpr) Eval

func (n *NegativeExpr) Eval(env envir.Environment) (interface{}, error)

func (*NegativeExpr) GetString

func (n *NegativeExpr) GetString() (string, error)

func (*NegativeExpr) Location

func (n *NegativeExpr) Location() string

func (*NegativeExpr) Lookup

func (n *NegativeExpr) Lookup(sym *envir.Symbols)

func (*NegativeExpr) NumChildren

func (n *NegativeExpr) NumChildren() int

type NotExpr

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

func NewNotExpr

func NewNotExpr(l *base.List[ASTree]) *NotExpr

func (*NotExpr) Child

func (n *NotExpr) Child(i int) (ASTree, error)

func (*NotExpr) Children

func (n *NotExpr) Children() *base.List[ASTree]

func (*NotExpr) Eval

func (n *NotExpr) Eval(env envir.Environment) (interface{}, error)

func (*NotExpr) GetString

func (n *NotExpr) GetString() (string, error)

func (*NotExpr) Location

func (n *NotExpr) Location() string

func (*NotExpr) Lookup

func (n *NotExpr) Lookup(sym *envir.Symbols)

func (*NotExpr) NumChildren

func (n *NotExpr) NumChildren() int

type NullStmt

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

func NewNullStmt

func NewNullStmt(l *base.List[ASTree]) *NullStmt

func (*NullStmt) Child

func (n *NullStmt) Child(i int) (ASTree, error)

func (*NullStmt) Children

func (n *NullStmt) Children() *base.List[ASTree]

func (*NullStmt) Eval

func (n *NullStmt) Eval(env envir.Environment) (interface{}, error)

func (*NullStmt) GetString

func (n *NullStmt) GetString() (string, error)

func (*NullStmt) Location

func (n *NullStmt) Location() string

func (*NullStmt) Lookup

func (n *NullStmt) Lookup(sym *envir.Symbols)

func (*NullStmt) NumChildren

func (n *NullStmt) NumChildren() int

type NumberLiteral

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

func NewNumberLiteral

func NewNumberLiteral(t token.Token) *NumberLiteral

func (*NumberLiteral) Child

func (n *NumberLiteral) Child(i int) (ASTree, error)

func (*NumberLiteral) Children

func (n *NumberLiteral) Children() *base.List[ASTree]

func (*NumberLiteral) Eval

func (n *NumberLiteral) Eval(env envir.Environment) (interface{}, error)

func (*NumberLiteral) GetString

func (n *NumberLiteral) GetString() (string, error)

func (*NumberLiteral) Location

func (n *NumberLiteral) Location() string

func (*NumberLiteral) Lookup

func (n *NumberLiteral) Lookup(sym *envir.Symbols)

func (*NumberLiteral) NumChildren

func (n *NumberLiteral) NumChildren() int

func (*NumberLiteral) String

func (n *NumberLiteral) String() string

func (*NumberLiteral) Value

func (n *NumberLiteral) Value() (interface{}, error)

type OptFunction

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

func NewOptFunction

func NewOptFunction(parameters *ParameterList,
	body *BlockStmt, en envir.Environment, memorySize int) *OptFunction

func (*OptFunction) Body

func (o *OptFunction) Body() *BlockStmt

func (*OptFunction) MakeEnv

func (o *OptFunction) MakeEnv() envir.Environment

func (*OptFunction) Parameters

func (o *OptFunction) Parameters() *ParameterList

type ParameterList

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

func NewParameterList

func NewParameterList(l *base.List[ASTree]) *ParameterList

func (*ParameterList) Child

func (p *ParameterList) Child(i int) (ASTree, error)

func (*ParameterList) Children

func (p *ParameterList) Children() *base.List[ASTree]

func (*ParameterList) Eval

func (p *ParameterList) Eval(env envir.Environment) (interface{}, error)

func (*ParameterList) Eval0

func (p *ParameterList) Eval0(env envir.Environment, index int, val interface{})

func (*ParameterList) GetString

func (p *ParameterList) GetString() (string, error)

func (*ParameterList) Location

func (p *ParameterList) Location() string

func (*ParameterList) Lookup

func (p *ParameterList) Lookup(sym *envir.Symbols)

func (*ParameterList) Name

func (p *ParameterList) Name(i int) (string, error)

func (*ParameterList) NumChildren

func (p *ParameterList) NumChildren() int

func (*ParameterList) Size

func (p *ParameterList) Size() int

type Postfix

type Postfix interface {
	Eval0(env envir.Environment, value interface{}) (interface{}, error)
}

type PrimaryExpr

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

func (*PrimaryExpr) Child

func (p *PrimaryExpr) Child(i int) (ASTree, error)

func (*PrimaryExpr) Children

func (p *PrimaryExpr) Children() *base.List[ASTree]

func (*PrimaryExpr) Eval

func (p *PrimaryExpr) Eval(env envir.Environment) (interface{}, error)

func (*PrimaryExpr) GetString

func (p *PrimaryExpr) GetString() (string, error)

func (*PrimaryExpr) HasPostfix

func (p *PrimaryExpr) HasPostfix(nest int) bool

func (*PrimaryExpr) Location

func (p *PrimaryExpr) Location() string

func (*PrimaryExpr) Lookup

func (p *PrimaryExpr) Lookup(sym *envir.Symbols)

func (*PrimaryExpr) NumChildren

func (p *PrimaryExpr) NumChildren() int

func (*PrimaryExpr) Operand

func (p *PrimaryExpr) Operand() (ASTree, error)

func (*PrimaryExpr) Postfix

func (p *PrimaryExpr) Postfix(nest int) Postfix

type ReturnSignal

type ReturnSignal struct {
	Val interface{}
}

type ReturnStmt

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

func NewReturnStmt

func NewReturnStmt(l *base.List[ASTree]) *ReturnStmt

func (*ReturnStmt) Child

func (r *ReturnStmt) Child(i int) (ASTree, error)

func (*ReturnStmt) Children

func (r *ReturnStmt) Children() *base.List[ASTree]

func (*ReturnStmt) Eval

func (r *ReturnStmt) Eval(env envir.Environment) (interface{}, error)

func (*ReturnStmt) GetString

func (r *ReturnStmt) GetString() (string, error)

func (*ReturnStmt) Location

func (r *ReturnStmt) Location() string

func (*ReturnStmt) Lookup

func (r *ReturnStmt) Lookup(sym *envir.Symbols)

func (*ReturnStmt) NumChildren

func (r *ReturnStmt) NumChildren() int

type StringLiteral

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

func NewStringLiteral

func NewStringLiteral(t token.Token) *StringLiteral

func (*StringLiteral) Child

func (s *StringLiteral) Child(i int) (ASTree, error)

func (*StringLiteral) Children

func (s *StringLiteral) Children() *base.List[ASTree]

func (*StringLiteral) Eval

func (s *StringLiteral) Eval(env envir.Environment) (interface{}, error)

func (*StringLiteral) GetString

func (s *StringLiteral) GetString() (string, error)

func (*StringLiteral) Location

func (s *StringLiteral) Location() string

func (*StringLiteral) Lookup

func (s *StringLiteral) Lookup(sym *envir.Symbols)

func (*StringLiteral) NumChildren

func (s *StringLiteral) NumChildren() int

func (*StringLiteral) Value

func (s *StringLiteral) Value() (string, error)

type WhileStmt

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

func NewWhileStmt

func NewWhileStmt(l *base.List[ASTree]) *WhileStmt

func (*WhileStmt) Body

func (w *WhileStmt) Body() (ASTree, error)

func (*WhileStmt) Child

func (w *WhileStmt) Child(i int) (ASTree, error)

func (*WhileStmt) Children

func (w *WhileStmt) Children() *base.List[ASTree]

func (*WhileStmt) Condition

func (w *WhileStmt) Condition() (ASTree, error)

func (*WhileStmt) Eval

func (w *WhileStmt) Eval(en envir.Environment) (interface{}, error)

func (*WhileStmt) GetString

func (w *WhileStmt) GetString() (string, error)

func (*WhileStmt) Location

func (w *WhileStmt) Location() string

func (*WhileStmt) Lookup

func (w *WhileStmt) Lookup(sym *envir.Symbols)

func (*WhileStmt) NumChildren

func (w *WhileStmt) NumChildren() int

Jump to

Keyboard shortcuts

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