ast

package
v1.0.18 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AssignTypeSingle = iota
	AssignTypeDeArray
	AssignTypeDeObject
)
View Source
const (
	CompareOpEQ = 1 + iota
	CompareOpNE
	CompareOpLT
	CompareOpLE
	CompareOpGT
	CompareOpGE
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayComprehension added in v1.0.4

type ArrayComprehension struct {
	ItemExpr Expr
	// contains filtered or unexported fields
}

func (*ArrayComprehension) Eval added in v1.0.4

func (e *ArrayComprehension) Eval(c *runtime.Context)

type ArrayItem

type ArrayItem struct {
	Expr         Expr
	ShouldExpand bool
}

type BinOp

type BinOp struct {
	Left, Right Expr
}

func (*BinOp) GetValues

func (binOp *BinOp) GetValues(c *runtime.Context) (runtime.Value, runtime.Value)

type Block

type Block struct {
	Pos
	Type  BlockType
	Stmts []Stmt
}

func (*Block) Eval

func (m *Block) Eval(c *runtime.Context)

type BlockType

type BlockType int
const (
	BlockTypeNormal BlockType = iota
	BlockTypeModuleTop
	BlockTypeFuncTop
	BlockTypeLoopTop
)

type CallArgument

type CallArgument struct {
	Keyword      string
	Arg          Expr
	ShouldExpand bool
}

type Case

type Case struct {
	Condition Expr
	Action    Expr
}

type Expr

type Expr interface {
	Node
}

type ExprArray

type ExprArray struct {
	Items []*ArrayItem
}

func (*ExprArray) Eval

func (e *ExprArray) Eval(c *runtime.Context)

type ExprAssertError

type ExprAssertError struct {
	Expr Expr
}

func (*ExprAssertError) Eval

func (e *ExprAssertError) Eval(c *runtime.Context)

type ExprAssign

type ExprAssign struct {
	Pos
	Lval Lval
	Expr Expr
}

func (*ExprAssign) Eval

func (assign *ExprAssign) Eval(c *runtime.Context)

type ExprBigNum

type ExprBigNum struct {
	Value runtime.ValueBigNum
}

func (*ExprBigNum) Eval

func (n *ExprBigNum) Eval(c *runtime.Context)

type ExprBitAnd

type ExprBitAnd struct {
	BinOp
}

func (*ExprBitAnd) Eval

func (expr *ExprBitAnd) Eval(c *runtime.Context)

type ExprBitNot

type ExprBitNot struct {
	Expr Expr
}

func (*ExprBitNot) Eval

func (e *ExprBitNot) Eval(c *runtime.Context)

type ExprBitOr

type ExprBitOr struct {
	BinOp
}

func (*ExprBitOr) Eval

func (expr *ExprBitOr) Eval(c *runtime.Context)

type ExprBitShl

type ExprBitShl struct {
	BinOp
}

func (*ExprBitShl) Eval

func (expr *ExprBitShl) Eval(c *runtime.Context)

type ExprBitShr

type ExprBitShr struct {
	BinOp
}

func (*ExprBitShr) Eval

func (expr *ExprBitShr) Eval(c *runtime.Context)

type ExprBitXor

type ExprBitXor struct {
	BinOp
}

func (*ExprBitXor) Eval

func (expr *ExprBitXor) Eval(c *runtime.Context)

type ExprBool

type ExprBool struct {
	Value runtime.ValueBool
}

func (*ExprBool) Eval

func (n *ExprBool) Eval(c *runtime.Context)

type ExprCall

type ExprCall struct {
	Pos
	Optional  bool
	Callee    Expr
	Arguments []CallArgument
}

func (*ExprCall) Eval

func (expr *ExprCall) Eval(c *runtime.Context)

func (*ExprCall) GetArgs

func (expr *ExprCall) GetArgs(c *runtime.Context, callable runtime.ValueCallable) []runtime.Value

type ExprCompare

type ExprCompare struct {
	First   Expr
	Ops     []int
	Targets []Expr
}

func (*ExprCompare) Eval

func (expr *ExprCompare) Eval(c *runtime.Context)

type ExprDiv

type ExprDiv struct {
	BinOp
}

func (*ExprDiv) Eval

func (n *ExprDiv) Eval(c *runtime.Context)

type ExprEqual

type ExprEqual struct {
	BinOp
}

func (*ExprEqual) Eval

func (expr *ExprEqual) Eval(c *runtime.Context)

type ExprFallback

type ExprFallback struct {
	BinOp
}

func (*ExprFallback) Eval

func (expr *ExprFallback) Eval(c *runtime.Context)

type ExprFloat

type ExprFloat struct {
	Value runtime.ValueFloat
}

func (*ExprFloat) Eval

func (n *ExprFloat) Eval(c *runtime.Context)

type ExprFunc

type ExprFunc struct {
	Value *runtime.ValueFunc
	Refs  map[string]runtime.Value
}

func (*ExprFunc) Eval

func (e *ExprFunc) Eval(c *runtime.Context)

type ExprGreaterEqual

type ExprGreaterEqual struct {
	BinOp
}

func (*ExprGreaterEqual) Eval

func (expr *ExprGreaterEqual) Eval(c *runtime.Context)

type ExprGreaterThen

type ExprGreaterThen struct {
	BinOp
}

func (*ExprGreaterThen) Eval

func (expr *ExprGreaterThen) Eval(c *runtime.Context)

type ExprIdentifier

type ExprIdentifier struct {
	Name string
}

func (*ExprIdentifier) Eval

func (expr *ExprIdentifier) Eval(c *runtime.Context)

type ExprIncDec

type ExprIncDec struct {
	Pos
	Lval Lval
	Expr Expr
	Pre  bool
}

func (*ExprIncDec) Eval

func (e *ExprIncDec) Eval(c *runtime.Context)

type ExprInt

type ExprInt struct {
	Value runtime.ValueInt
}

func (*ExprInt) Eval

func (n *ExprInt) Eval(c *runtime.Context)

type ExprIsType added in v1.0.8

type ExprIsType struct {
	BinOp
}

func (*ExprIsType) Eval added in v1.0.8

func (expr *ExprIsType) Eval(c *runtime.Context)

type ExprLessEqual

type ExprLessEqual struct {
	BinOp
}

func (*ExprLessEqual) Eval

func (expr *ExprLessEqual) Eval(c *runtime.Context)

type ExprLessThen

type ExprLessThen struct {
	BinOp
}

func (*ExprLessThen) Eval

func (expr *ExprLessThen) Eval(c *runtime.Context)

type ExprLocalAssign

type ExprLocalAssign struct {
	Pos
	Names      []string
	ExpandLast bool
	Type       int
	Expr       Expr
}

func (*ExprLocalAssign) Eval

func (assign *ExprLocalAssign) Eval(c *runtime.Context)

type ExprLocalNewAssign

type ExprLocalNewAssign struct {
	Pos
	Expr Expr
}

func (*ExprLocalNewAssign) Eval

func (assign *ExprLocalNewAssign) Eval(c *runtime.Context)

type ExprLogicAnd

type ExprLogicAnd struct {
	BinOp
}

func (*ExprLogicAnd) Eval

func (expr *ExprLogicAnd) Eval(c *runtime.Context)

type ExprLogicNot

type ExprLogicNot struct {
	Expr Expr
}

func (*ExprLogicNot) Eval

func (expr *ExprLogicNot) Eval(c *runtime.Context)

type ExprLogicOr

type ExprLogicOr struct {
	BinOp
}

func (*ExprLogicOr) Eval

func (expr *ExprLogicOr) Eval(c *runtime.Context)

type ExprMinus

type ExprMinus struct {
	BinOp
}

func (*ExprMinus) Eval

func (n *ExprMinus) Eval(c *runtime.Context)

type ExprMod

type ExprMod struct {
	BinOp
}

func (*ExprMod) Eval

func (n *ExprMod) Eval(c *runtime.Context)

type ExprNegative

type ExprNegative struct {
	Expr Expr
}

func (*ExprNegative) Eval

func (e *ExprNegative) Eval(c *runtime.Context)

type ExprNil

type ExprNil struct {
}

func (*ExprNil) Eval

func (n *ExprNil) Eval(c *runtime.Context)

type ExprNotEqual

type ExprNotEqual struct {
	BinOp
}

func (*ExprNotEqual) Eval

func (expr *ExprNotEqual) Eval(c *runtime.Context)

type ExprObject

type ExprObject struct {
	Items []interface{}
}

func (*ExprObject) Eval

func (e *ExprObject) Eval(c *runtime.Context)

type ExprObjectItemExpandObj

type ExprObjectItemExpandObj struct {
	Obj Expr
}

type ExprObjectItemKV

type ExprObjectItemKV struct {
	Key, Value Expr
}

type ExprPlus

type ExprPlus struct {
	BinOp
}

func (*ExprPlus) Eval

func (n *ExprPlus) Eval(c *runtime.Context)

type ExprPow

type ExprPow struct {
	BinOp
}

func (*ExprPow) Eval

func (n *ExprPow) Eval(c *runtime.Context)

type ExprShortImport

type ExprShortImport struct {
	ImportPath string
}

func (*ExprShortImport) Eval

func (e *ExprShortImport) Eval(c *runtime.Context)

type ExprStr

type ExprStr struct {
	Value runtime.ValueStr
}

func (*ExprStr) Eval

func (n *ExprStr) Eval(c *runtime.Context)

type ExprTimes

type ExprTimes struct {
	BinOp
}

func (*ExprTimes) Eval

func (n *ExprTimes) Eval(c *runtime.Context)

type ExprToStr

type ExprToStr struct {
	Expr Expr
}

func (*ExprToStr) Eval

func (n *ExprToStr) Eval(c *runtime.Context)

type ExprUndefined

type ExprUndefined struct {
}

func (*ExprUndefined) Eval

func (n *ExprUndefined) Eval(c *runtime.Context)

type ExprUse

type ExprUse struct {
	Expr       Expr
	Identifier string
	DeferFunc  ExprFunc
}

func (*ExprUse) Eval

func (e *ExprUse) Eval(c *runtime.Context)

type ExprWhen

type ExprWhen struct {
	Cases []Case
	Else  Expr
}

func (*ExprWhen) Eval

func (expr *ExprWhen) Eval(c *runtime.Context)

type ExprWhenValue

type ExprWhenValue struct {
	Input Expr
	Cases []ValueCondition

	Else Expr
}

func (*ExprWhenValue) Eval

func (expr *ExprWhenValue) Eval(c *runtime.Context)

type IfCase

type IfCase struct {
	Check      Expr
	Assignment Expr
	Do         *Block
}

type IsAssign added in v1.0.12

type IsAssign interface {
	// contains filtered or unexported methods
}

type Lval

type Lval interface {
	Expr
	GetOwner(*runtime.Context) runtime.Value
	SetValue(*runtime.Context, runtime.Value)
}

type LvalByField

type LvalByField struct {
	Owner Expr
	Field Expr
}

func (*LvalByField) Eval

func (v *LvalByField) Eval(c *runtime.Context)

func (*LvalByField) GetOwner

func (v *LvalByField) GetOwner(c *runtime.Context) runtime.Value

func (*LvalByField) SetValue

func (v *LvalByField) SetValue(c *runtime.Context, val runtime.Value)

type LvalById

type LvalById struct {
	Name string
}

func (*LvalById) Eval

func (v *LvalById) Eval(c *runtime.Context)

func (*LvalById) GetOwner

func (v *LvalById) GetOwner(*runtime.Context) runtime.Value

func (*LvalById) SetValue

func (v *LvalById) SetValue(c *runtime.Context, val runtime.Value)

type Module

type Module struct {
	Block *Block
}

func (*Module) Eval

func (m *Module) Eval(c *runtime.Context)

type Node

type Node interface {
	runtime.IEval
}

type ObjectComprehension added in v1.0.4

type ObjectComprehension struct {
	KeyExpr   Expr
	ValueExpr Expr
	// contains filtered or unexported fields
}

func (*ObjectComprehension) Eval added in v1.0.4

func (e *ObjectComprehension) Eval(c *runtime.Context)

type Pos

type Pos struct {
	FileName string
	Line     int
}

func (*Pos) Position

func (p *Pos) Position() (string, int)

func (*Pos) PositionStr

func (p *Pos) PositionStr() string

type Position

type Position interface {
	Position() (fileName string, lineNum int)
}

type SetResult added in v1.0.4

type SetResult = func(c *runtime.Context)

type Stmt

type Stmt interface {
	Node
	Position
}

type StmtAssert

type StmtAssert struct {
	Pos
	Expr    Expr
	Message Expr
}

func (*StmtAssert) Eval

func (s *StmtAssert) Eval(c *runtime.Context)

type StmtBlockDefer

type StmtBlockDefer struct {
	Pos
	Call *ExprCall
}

func (*StmtBlockDefer) Eval

func (s *StmtBlockDefer) Eval(c *runtime.Context)

type StmtBreak

type StmtBreak struct {
	Pos
	Level   int
	ToLabel string
}

func (*StmtBreak) Eval

func (s *StmtBreak) Eval(c *runtime.Context)

type StmtClassDefine

type StmtClassDefine struct {
	Pos
	Exported bool
	Name     string
	Bases    []Expr
	Body     *ExprObject
	Static   *ExprObject
}

func (*StmtClassDefine) Eval

func (s *StmtClassDefine) Eval(c *runtime.Context)

type StmtContinue

type StmtContinue struct {
	Pos
	Level   int
	ToLabel string
}

func (*StmtContinue) Eval

func (s *StmtContinue) Eval(c *runtime.Context)

type StmtDefer

type StmtDefer struct {
	Pos
	Call *ExprCall
}

func (*StmtDefer) Eval

func (s *StmtDefer) Eval(c *runtime.Context)

type StmtDoWhile

type StmtDoWhile struct {
	Pos
	Label string
	Check Expr
	Exec  *Block
}

func (*StmtDoWhile) Eval

func (s *StmtDoWhile) Eval(c *runtime.Context)

type StmtExport

type StmtExport struct {
	Pos
	Name string
	Expr Expr
}

func (*StmtExport) Eval

func (s *StmtExport) Eval(c *runtime.Context)

type StmtExtend

type StmtExtend struct {
	Pos
	Exported bool
	Type     Expr
	Name     []Expr
	Func     []Expr
}

func (*StmtExtend) Eval

func (s *StmtExtend) Eval(c *runtime.Context)

type StmtFallback

type StmtFallback struct {
	Pos
	Stmt     Stmt
	Fallback *Block
}

func (*StmtFallback) Eval

func (s *StmtFallback) Eval(c *runtime.Context)

type StmtFor

type StmtFor struct {
	Pos
	Label string
	Init  Expr
	Check Expr
	Next  Expr
	Exec  *Block
}

func (*StmtFor) Eval

func (s *StmtFor) Eval(c *runtime.Context)

type StmtForEach

type StmtForEach struct {
	Pos
	Label             string
	IdIndex           string
	IdValue           string
	Iteratable        Expr
	RangeBegin        Expr
	RangeEnd          Expr
	RangeIncludingEnd bool
	Exec              *Block
}

func (*StmtForEach) Eval

func (s *StmtForEach) Eval(c *runtime.Context)

type StmtIf

type StmtIf struct {
	Pos
	Cases  []*IfCase
	ElseDo *Block
}

func (*StmtIf) Eval

func (s *StmtIf) Eval(c *runtime.Context)

type StmtReturn

type StmtReturn struct {
	Pos
	Value Expr
}

func (*StmtReturn) Eval

func (s *StmtReturn) Eval(c *runtime.Context)

type StmtSwitch

type StmtSwitch struct {
	Pos
	Val     Expr
	Cases   []SwitchCase
	Default *Block
}

func (*StmtSwitch) Eval

func (s *StmtSwitch) Eval(c *runtime.Context)

type StmtTry

type StmtTry struct {
	Pos
	Try     *Block
	Catch   *Block
	ExcName string
	Finally *Block
}

func (*StmtTry) Eval

func (s *StmtTry) Eval(c *runtime.Context)

type StmtWhile

type StmtWhile struct {
	Pos
	Label string
	Check Expr
	Exec  *Block
}

func (*StmtWhile) Eval

func (s *StmtWhile) Eval(c *runtime.Context)

type SwitchCase

type SwitchCase struct {
	Condition   ValueCondition
	Code        *Block
	Fallthrough bool
}

type ValueCondition

type ValueCondition interface {
	IsMatch(*runtime.Context, runtime.Value) bool
	Return(*runtime.Context)
}

type ValueConditionInList

type ValueConditionInList struct {
	ValueList []Expr
	Ret       Expr
}

func (*ValueConditionInList) IsMatch

func (*ValueConditionInList) Return

func (vc *ValueConditionInList) Return(c *runtime.Context)

type ValueConditionInRange

type ValueConditionInRange struct {
	Min, Max               Expr
	IncludeMin, IncludeMax bool
	Ret                    Expr
}

func (*ValueConditionInRange) IsMatch

func (*ValueConditionInRange) Return

func (vc *ValueConditionInRange) Return(c *runtime.Context)

type ValueConditionIsType added in v1.0.8

type ValueConditionIsType struct {
	ExpectedType Expr
	Ret          Expr
}

func (*ValueConditionIsType) IsMatch added in v1.0.8

func (*ValueConditionIsType) Return added in v1.0.8

func (vc *ValueConditionIsType) Return(c *runtime.Context)

Jump to

Keyboard shortcuts

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