ast

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddVariable

func AddVariable(ctx *Context, name string, pos token.Pos) symbol.Symbol

Don't forget to call emitVariableInit for new variables.

func AddVariableToScope

func AddVariableToScope(ctx *Context, scope *symbol.Scope, name string, pos token.Pos) symbol.Symbol

Don't forget to call emitVariableInit for new variables.

Types

type AST

type AST interface {
	PassRunner
	Pos() token.Pos
	SetPos(pos token.Pos)
}

type ASTs

type ASTs []AST

func (ASTs) Pos

func (asts ASTs) Pos() token.Pos

func (ASTs) RunPass

func (asts ASTs) RunPass(ctx *Context, pass Pass)

func (ASTs) SetPos

func (asts ASTs) SetPos(pos token.Pos)

type AndExpr

type AndExpr struct {
	Left  Expr
	Right Expr
	// contains filtered or unexported fields
}

func (*AndExpr) Pos

func (b *AndExpr) Pos() token.Pos

func (*AndExpr) RunPass

func (e *AndExpr) RunPass(ctx *Context, pass Pass)

func (*AndExpr) SetPos

func (b *AndExpr) SetPos(pos token.Pos)

type AnonFuncExpr

type AnonFuncExpr struct {
	Func
}

func (*AnonFuncExpr) Pos

func (b *AnonFuncExpr) Pos() token.Pos

func (*AnonFuncExpr) RunPass

func (e *AnonFuncExpr) RunPass(ctx *Context, pass Pass)

func (*AnonFuncExpr) SetPos

func (b *AnonFuncExpr) SetPos(pos token.Pos)

type ArrayElement

type ArrayElement struct {
	Val Expr
	// contains filtered or unexported fields
}

func (*ArrayElement) Pos

func (b *ArrayElement) Pos() token.Pos

func (*ArrayElement) RunPass

func (e *ArrayElement) RunPass(ctx *Context, pass Pass)

func (*ArrayElement) SetPos

func (b *ArrayElement) SetPos(pos token.Pos)

type ArrayElementBlock

type ArrayElementBlock struct {
	Elements ASTs
	// contains filtered or unexported fields
}

func (*ArrayElementBlock) Pos

func (b *ArrayElementBlock) Pos() token.Pos

func (*ArrayElementBlock) RunPass

func (b *ArrayElementBlock) RunPass(ctx *Context, pass Pass)

func (*ArrayElementBlock) Scope

func (b *ArrayElementBlock) Scope() *symbol.Scope

func (*ArrayElementBlock) SetPos

func (b *ArrayElementBlock) SetPos(pos token.Pos)

type ArrayLiteral

type ArrayLiteral struct {
	Block *ArrayElementBlock
	// contains filtered or unexported fields
}

func (*ArrayLiteral) Pos

func (b *ArrayLiteral) Pos() token.Pos

func (*ArrayLiteral) RunPass

func (a *ArrayLiteral) RunPass(ctx *Context, pass Pass)

func (*ArrayLiteral) Scope

func (a *ArrayLiteral) Scope() *symbol.Scope

func (*ArrayLiteral) SetPos

func (b *ArrayLiteral) SetPos(pos token.Pos)

type AssignOpStmt added in v0.2.0

type AssignOpStmt struct {
	Op     Operator
	LValue *LValue
	RValue Expr
	// contains filtered or unexported fields
}

func (*AssignOpStmt) Pos added in v0.2.0

func (b *AssignOpStmt) Pos() token.Pos

func (*AssignOpStmt) RunPass added in v0.2.0

func (s *AssignOpStmt) RunPass(ctx *Context, pass Pass)

func (*AssignOpStmt) SetPos added in v0.2.0

func (b *AssignOpStmt) SetPos(pos token.Pos)

type AssignOperator added in v0.2.0

type AssignOperator int

type AssignStmt

type AssignStmt struct {
	Lvalues ASTs
	Rvalues Exprs
	// contains filtered or unexported fields
}

func (*AssignStmt) Pos

func (b *AssignStmt) Pos() token.Pos

func (*AssignStmt) RunPass

func (s *AssignStmt) RunPass(ctx *Context, pass Pass)

func (*AssignStmt) SetPos

func (b *AssignStmt) SetPos(pos token.Pos)

type BinaryExpr

type BinaryExpr struct {
	Left  Expr
	Op    Operator
	Right Expr
	// contains filtered or unexported fields
}

func (*BinaryExpr) Pos

func (b *BinaryExpr) Pos() token.Pos

func (*BinaryExpr) RunPass

func (e *BinaryExpr) RunPass(ctx *Context, pass Pass)

func (*BinaryExpr) SetPos

func (b *BinaryExpr) SetPos(pos token.Pos)

type BreakContinueEmitter

type BreakContinueEmitter interface {
	EmitBreak(pos token.Pos, emitter *vm.Emitter)
	EmitContinue(pos token.Pos, emitter *vm.Emitter)
}

type BreakStmt

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

func (*BreakStmt) Pos

func (b *BreakStmt) Pos() token.Pos

func (*BreakStmt) RunPass

func (s *BreakStmt) RunPass(ctx *Context, pass Pass)

func (*BreakStmt) SetPos

func (b *BreakStmt) SetPos(pos token.Pos)

type Context

type Context struct {
	Stack
	*errlogger.ErrLoggerWrapper
	// contains filtered or unexported fields
}

func NewContext

func NewContext(
	moduleRegistry *ModuleRegistry,
	l *errlogger.ErrLoggerWrapper,
) *Context

func (*Context) CurrentFunc

func (c *Context) CurrentFunc() *Func

func (*Context) CurrentScope

func (c *Context) CurrentScope() *symbol.Scope

func (*Context) Emitter

func (c *Context) Emitter() *vm.Emitter

func (*Context) FindSymbol

func (c *Context) FindSymbol(symName string) symbol.Symbol

func (*Context) IsInLiftableScope

func (c *Context) IsInLiftableScope() bool

func (*Context) Len

func (c *Context) Len() int

func (*Context) Main

func (c *Context) Main() *Main

func (*Context) ModuleRegistry

func (c *Context) ModuleRegistry() *ModuleRegistry

func (*Context) Parent

func (c *Context) Parent() AST

func (*Context) Peek

func (c *Context) Peek(n int) AST

func (*Context) RunPassChild

func (c *Context) RunPassChild(parent AST, child AST, pass Pass)

type ContinueStmt

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

func (*ContinueStmt) Pos

func (b *ContinueStmt) Pos() token.Pos

func (*ContinueStmt) RunPass

func (s *ContinueStmt) RunPass(ctx *Context, pass Pass)

func (*ContinueStmt) SetPos

func (b *ContinueStmt) SetPos(pos token.Pos)

type DeferStmt

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

func NewDeferStmt

func NewDeferStmt(callExpr *FuncCallExpr) *DeferStmt

func (*DeferStmt) Pos

func (b *DeferStmt) Pos() token.Pos

func (*DeferStmt) RunPass

func (s *DeferStmt) RunPass(ctx *Context, pass Pass)

func (*DeferStmt) SetPos

func (b *DeferStmt) SetPos(pos token.Pos)

type Expr

type Expr interface {
	AST
	// contains filtered or unexported methods
}

type ExprStmt

type ExprStmt struct {
	Expr Expr
	// contains filtered or unexported fields
}

func (*ExprStmt) Pos

func (b *ExprStmt) Pos() token.Pos

func (*ExprStmt) RunPass

func (c *ExprStmt) RunPass(ctx *Context, pass Pass)

func (*ExprStmt) SetPos

func (b *ExprStmt) SetPos(pos token.Pos)

type Exprs

type Exprs []Expr

func (Exprs) Pos

func (exprs Exprs) Pos() token.Pos

func (Exprs) RunPass

func (exprs Exprs) RunPass(ctx *Context, pass Pass)

func (Exprs) SetPos

func (exprs Exprs) SetPos(pos token.Pos)

type ExternFn

type ExternFn struct {
	Name     string
	ExternFn *vm.NativeFn
	// contains filtered or unexported fields
}

func (*ExternFn) Pos

func (b *ExternFn) Pos() token.Pos

func (*ExternFn) RunPass

func (f *ExternFn) RunPass(ctx *Context, pass Pass)

func (*ExternFn) SetPos

func (b *ExternFn) SetPos(pos token.Pos)

type ForStmt

type ForStmt struct {
	ForVars  ASTs
	IterExpr Expr
	Block    AST
	// contains filtered or unexported fields
}

func (*ForStmt) EmitBreak

func (s *ForStmt) EmitBreak(pos token.Pos, e *vm.Emitter)

func (*ForStmt) EmitContinue

func (s *ForStmt) EmitContinue(pos token.Pos, e *vm.Emitter)

func (*ForStmt) IsLiftableScope

func (s *ForStmt) IsLiftableScope()

func (*ForStmt) Pos

func (b *ForStmt) Pos() token.Pos

func (*ForStmt) RunPass

func (s *ForStmt) RunPass(ctx *Context, pass Pass)

func (*ForStmt) Scope

func (s *ForStmt) Scope() *symbol.Scope

func (*ForStmt) SetPos

func (b *ForStmt) SetPos(pos token.Pos)

type ForVar

type ForVar struct {
	VarName token.Token
	// contains filtered or unexported fields
}

func (*ForVar) Pos

func (b *ForVar) Pos() token.Pos

func (*ForVar) RunPass

func (s *ForVar) RunPass(ctx *Context, pass Pass)

func (*ForVar) SetPos

func (b *ForVar) SetPos(pos token.Pos)

type Func

type Func struct {
	Params    ASTs
	Block     *StmtBlock
	IsClosure bool
	DebugName string
	// contains filtered or unexported fields
}

func (*Func) IdxFunc

func (f *Func) IdxFunc() int

func (*Func) IsIter

func (f *Func) IsIter() bool

func (*Func) IsLiftableScope

func (f *Func) IsLiftableScope()

func (*Func) IterNRet

func (f *Func) IterNRet() int

func (*Func) NewCapture

func (f *Func) NewCapture(sym symbol.Symbol) *symbol.CaptureSymbol

func (*Func) NewLocal

func (f *Func) NewLocal() *symbol.LocalVarSymbol

func (*Func) NewParam

func (f *Func) NewParam() *symbol.ParamSymbol

func (*Func) Pos

func (b *Func) Pos() token.Pos

func (*Func) RunPass

func (f *Func) RunPass(ctx *Context, pass Pass)

func (*Func) Scope

func (f *Func) Scope() *symbol.Scope

func (*Func) SetIterNRet

func (f *Func) SetIterNRet(nret int)

func (*Func) SetPos

func (b *Func) SetPos(pos token.Pos)

type FuncCallExpr

type FuncCallExpr struct {
	Target   Expr
	Args     Exprs
	RetN     int
	Expand   bool
	Pipeline bool
	// contains filtered or unexported fields
}

func (*FuncCallExpr) Pos

func (b *FuncCallExpr) Pos() token.Pos

func (*FuncCallExpr) RunPass

func (c *FuncCallExpr) RunPass(ctx *Context, pass Pass)

func (*FuncCallExpr) SetPos

func (b *FuncCallExpr) SetPos(pos token.Pos)

type FuncParam

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

func (*FuncParam) Pos

func (b *FuncParam) Pos() token.Pos

func (*FuncParam) RunPass

func (p *FuncParam) RunPass(ctx *Context, pass Pass)

func (*FuncParam) SetPos

func (b *FuncParam) SetPos(pos token.Pos)

type FuncStmt

type FuncStmt struct {
	Func

	Name string
	// contains filtered or unexported fields
}

func (*FuncStmt) Pos

func (b *FuncStmt) Pos() token.Pos

func (*FuncStmt) RunPass

func (s *FuncStmt) RunPass(ctx *Context, pass Pass)

func (*FuncStmt) SetPos

func (b *FuncStmt) SetPos(pos token.Pos)

type GraphPrinter

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

func NewGraphPrinter

func NewGraphPrinter(out io.Writer) *GraphPrinter

func (*GraphPrinter) PrintGraph

func (p *GraphPrinter) PrintGraph(root Printer)

func (*GraphPrinter) PrintNode

func (p *GraphPrinter) PrintNode(label string, children ...Printer)

type IfBlock

type IfBlock struct {
	Pred  Expr
	Block AST
	// contains filtered or unexported fields
}

func (*IfBlock) Pos

func (b *IfBlock) Pos() token.Pos

func (*IfBlock) RunPass

func (b *IfBlock) RunPass(ctx *Context, pass Pass)

func (*IfBlock) SetPos

func (b *IfBlock) SetPos(pos token.Pos)

type IfStmt

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

func (*IfStmt) Pos

func (b *IfStmt) Pos() token.Pos

func (*IfStmt) RunPass

func (s *IfStmt) RunPass(ctx *Context, pass Pass)

func (*IfStmt) SetPos

func (b *IfStmt) SetPos(pos token.Pos)

type Import

type Import struct {
	Alias      string
	ModuleName string

	ModuleRef *symbol.ModuleRef
	// contains filtered or unexported fields
}

func (*Import) Pos

func (b *Import) Pos() token.Pos

func (*Import) RunPass

func (i *Import) RunPass(ctx *Context, pass Pass)

func (*Import) SetPos

func (b *Import) SetPos(pos token.Pos)

type IncDecOp added in v0.2.0

type IncDecOp int
const (
	IncDecOpUndefined IncDecOp = iota
	IncDecOpInc
	IncDecOpDec
)

type IncDecStmt added in v0.2.0

type IncDecStmt struct {
	LValue *LValue
	Op     IncDecOp
	// contains filtered or unexported fields
}

func (*IncDecStmt) Pos added in v0.2.0

func (b *IncDecStmt) Pos() token.Pos

func (*IncDecStmt) RunPass added in v0.2.0

func (s *IncDecStmt) RunPass(ctx *Context, pass Pass)

func (*IncDecStmt) SetPos added in v0.2.0

func (b *IncDecStmt) SetPos(pos token.Pos)

type IndexExpr

type IndexExpr struct {
	Target Expr
	Index  Expr
	// contains filtered or unexported fields
}

func (*IndexExpr) Pos

func (b *IndexExpr) Pos() token.Pos

func (*IndexExpr) RunPass

func (e *IndexExpr) RunPass(ctx *Context, pass Pass)

func (*IndexExpr) SetPos

func (b *IndexExpr) SetPos(pos token.Pos)

type LValue

type LValue struct {
	Expr Expr
	// contains filtered or unexported fields
}

func (*LValue) Pos

func (b *LValue) Pos() token.Pos

func (*LValue) RunPass

func (v *LValue) RunPass(ctx *Context, pass Pass)

func (*LValue) SetPos

func (b *LValue) SetPos(pos token.Pos)

type LiftableScope

type LiftableScope interface {
	IsLiftableScope()
}

type LiteralExpr

type LiteralExpr struct {
	Val token.Token
	// contains filtered or unexported fields
}

func (*LiteralExpr) Pos

func (b *LiteralExpr) Pos() token.Pos

func (*LiteralExpr) RunPass

func (e *LiteralExpr) RunPass(ctx *Context, pass Pass)

func (*LiteralExpr) SetPos

func (b *LiteralExpr) SetPos(pos token.Pos)

type Main

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

func (*Main) AddGlobalParam

func (m *Main) AddGlobalParam(ctx *Context, name string, param *meta.Param, pos token.Pos) symbol.Symbol

func (*Main) AddModule

func (m *Main) AddModule(module AST)

func (*Main) AddNativeFn

func (m *Main) AddNativeFn(name string, extFn *vm.NativeFn)

func (*Main) Metadata

func (m *Main) Metadata() *meta.Metadata

func (*Main) NewGlobal

func (m *Main) NewGlobal() *symbol.GlobalVarSymbol

func (*Main) Pos

func (b *Main) Pos() token.Pos

func (*Main) RunPass

func (m *Main) RunPass(ctx *Context, pass Pass)

func (*Main) Scope

func (m *Main) Scope() *symbol.Scope

func (*Main) SetPos

func (b *Main) SetPos(pos token.Pos)

type MemberAccess

type MemberAccess struct {
	Target Expr
	Member token.Token

	ModuleMember symbol.Symbol
	// contains filtered or unexported fields
}

func (*MemberAccess) Pos

func (b *MemberAccess) Pos() token.Pos

func (*MemberAccess) RunPass

func (a *MemberAccess) RunPass(ctx *Context, pass Pass)

func (*MemberAccess) SetPos

func (b *MemberAccess) SetPos(pos token.Pos)

type MetaAttrib

type MetaAttrib struct {
	Name  string
	Value vm.Value
	// contains filtered or unexported fields
}

func (*MetaAttrib) Pos

func (b *MetaAttrib) Pos() token.Pos

func (*MetaAttrib) RunPass

func (a *MetaAttrib) RunPass(ctx *Context, pass Pass)

func (*MetaAttrib) SetPos

func (b *MetaAttrib) SetPos(pos token.Pos)

type MetaParam

type MetaParam struct {
	Name    string
	IsFlag  bool
	Default Expr
	Attribs ASTs
	// contains filtered or unexported fields
}

func (*MetaParam) Pos

func (b *MetaParam) Pos() token.Pos

func (*MetaParam) RunPass

func (p *MetaParam) RunPass(ctx *Context, pass Pass)

func (*MetaParam) SetPos

func (b *MetaParam) SetPos(pos token.Pos)

type ModuleRegistry

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

func NewModuleRegistry

func NewModuleRegistry() *ModuleRegistry

func (*ModuleRegistry) AddModule

func (r *ModuleRegistry) AddModule(name string, m *symbol.Module)

func (*ModuleRegistry) GetModule

func (r *ModuleRegistry) GetModule(name string) *symbol.Module

func (*ModuleRegistry) GetNativeLoader

func (r *ModuleRegistry) GetNativeLoader(name string) func(r NativeModuleContext)

func (*ModuleRegistry) RegisterNativeModuleLoader

func (r *ModuleRegistry) RegisterNativeModuleLoader(
	name string,
	regFn func(r NativeModuleContext),
) error

type NativeModuleContext

type NativeModuleContext interface {
	RegisterNativeFn(name string, natFn func(m *vm.VM, args []vm.Value, nRet int) ([]vm.Value, error))
}

type Nop

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

func (*Nop) Pos

func (b *Nop) Pos() token.Pos

func (*Nop) RunPass

func (n *Nop) RunPass(ctx *Context, pass Pass)

func (*Nop) SetPos

func (b *Nop) SetPos(pos token.Pos)

type ObjectField

type ObjectField struct {
	NameID   string
	NameExpr Expr
	Val      Expr
	// contains filtered or unexported fields
}

func (*ObjectField) Pos

func (b *ObjectField) Pos() token.Pos

func (*ObjectField) RunPass

func (s *ObjectField) RunPass(ctx *Context, pass Pass)

func (*ObjectField) SetPos

func (b *ObjectField) SetPos(pos token.Pos)

type ObjectFieldBlock

type ObjectFieldBlock struct {
	Fields ASTs
	// contains filtered or unexported fields
}

func (*ObjectFieldBlock) Pos

func (b *ObjectFieldBlock) Pos() token.Pos

func (*ObjectFieldBlock) RunPass

func (b *ObjectFieldBlock) RunPass(ctx *Context, pass Pass)

func (*ObjectFieldBlock) Scope

func (b *ObjectFieldBlock) Scope() *symbol.Scope

func (*ObjectFieldBlock) SetPos

func (b *ObjectFieldBlock) SetPos(pos token.Pos)

type ObjectLiteral

type ObjectLiteral struct {
	FieldBlock *ObjectFieldBlock
	// contains filtered or unexported fields
}

func (*ObjectLiteral) Pos

func (b *ObjectLiteral) Pos() token.Pos

func (*ObjectLiteral) RunPass

func (s *ObjectLiteral) RunPass(ctx *Context, pass Pass)

func (*ObjectLiteral) Scope

func (s *ObjectLiteral) Scope() *symbol.Scope

func (*ObjectLiteral) SetPos

func (b *ObjectLiteral) SetPos(pos token.Pos)

type Operator

type Operator int
const (
	BinOpPlus Operator = iota
	BinOpMinus
	BinOpMult
	BinOpDiv
	BinOpMod
	BinOpLT
	BinOpLE
	BinOpGT
	BinOpGE
	BinOpEq
	BinOpNE
)

type OrExpr

type OrExpr struct {
	Left  Expr
	Right Expr
	// contains filtered or unexported fields
}

func (*OrExpr) Pos

func (b *OrExpr) Pos() token.Pos

func (*OrExpr) RunPass

func (e *OrExpr) RunPass(ctx *Context, pass Pass)

func (*OrExpr) SetPos

func (b *OrExpr) SetPos(pos token.Pos)

type Pass

type Pass int
const (
	Print Pass = iota

	Rewrite
	Check
	Emit
)

type PassRunner

type PassRunner interface {
	RunPass(ctx *Context, pass Pass)
}

type Printer

type Printer interface {
	Print(p *GraphPrinter)
}

type RegexLiteral

type RegexLiteral struct {
	RegexDef string
	// contains filtered or unexported fields
}

func (*RegexLiteral) Pos

func (b *RegexLiteral) Pos() token.Pos

func (*RegexLiteral) RunPass

func (l *RegexLiteral) RunPass(ctx *Context, pass Pass)

func (*RegexLiteral) SetPos

func (b *RegexLiteral) SetPos(pos token.Pos)

type ReturnStmt

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

func (*ReturnStmt) Pos

func (b *ReturnStmt) Pos() token.Pos

func (*ReturnStmt) RunPass

func (s *ReturnStmt) RunPass(ctx *Context, pass Pass)

func (*ReturnStmt) SetPos

func (b *ReturnStmt) SetPos(pos token.Pos)

type Scope

type Scope interface {
	Scope() *symbol.Scope
}

type SimpleRef

type SimpleRef struct {
	ID token.Token

	ModuleRef *symbol.ModuleRef
	// contains filtered or unexported fields
}

func (*SimpleRef) Pos

func (b *SimpleRef) Pos() token.Pos

func (*SimpleRef) RunPass

func (r *SimpleRef) RunPass(ctx *Context, pass Pass)

func (*SimpleRef) SetPos

func (b *SimpleRef) SetPos(pos token.Pos)

type SliceExpr

type SliceExpr struct {
	Target Expr
	Begin  Expr
	End    Expr
	// contains filtered or unexported fields
}

func (*SliceExpr) Pos

func (b *SliceExpr) Pos() token.Pos

func (*SliceExpr) RunPass

func (e *SliceExpr) RunPass(ctx *Context, pass Pass)

func (*SliceExpr) SetPos

func (b *SliceExpr) SetPos(pos token.Pos)

type Stack

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

func (*Stack) Pop

func (s *Stack) Pop()

func (*Stack) Push

func (s *Stack) Push(ast AST)

type StmtBlock

type StmtBlock struct {
	Stmts ASTs
	// contains filtered or unexported fields
}

func (*StmtBlock) Pos

func (b *StmtBlock) Pos() token.Pos

func (*StmtBlock) RunPass

func (b *StmtBlock) RunPass(ctx *Context, pass Pass)

func (*StmtBlock) Scope

func (b *StmtBlock) Scope() *symbol.Scope

func (*StmtBlock) SetPos

func (b *StmtBlock) SetPos(pos token.Pos)

type TernaryExpr

type TernaryExpr struct {
	Condition Expr
	Then      Expr
	Else      Expr
	// contains filtered or unexported fields
}

func (*TernaryExpr) Pos

func (b *TernaryExpr) Pos() token.Pos

func (*TernaryExpr) RunPass

func (e *TernaryExpr) RunPass(ctx *Context, pass Pass)

func (*TernaryExpr) SetPos

func (b *TernaryExpr) SetPos(pos token.Pos)

type ThrowStmt

type ThrowStmt struct {
	Expr Expr
	// contains filtered or unexported fields
}

func (*ThrowStmt) Pos

func (b *ThrowStmt) Pos() token.Pos

func (*ThrowStmt) RunPass

func (s *ThrowStmt) RunPass(ctx *Context, pass Pass)

func (*ThrowStmt) SetPos

func (b *ThrowStmt) SetPos(pos token.Pos)

type TryCatchStmt

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

func NewTryCatchStmt

func NewTryCatchStmt(
	tryBlock AST,
	catchVar *token.Token,
	catchStmts AST,
) *TryCatchStmt

func (*TryCatchStmt) Pos

func (b *TryCatchStmt) Pos() token.Pos

func (*TryCatchStmt) RunPass

func (s *TryCatchStmt) RunPass(ctx *Context, pass Pass)

func (*TryCatchStmt) SetPos

func (b *TryCatchStmt) SetPos(pos token.Pos)

type Type

type Type int
const (
	Number Type = iota
	String
	Bool
)

type UnaryExpr

type UnaryExpr struct {
	Term Expr
	Op   UnaryOp
	// contains filtered or unexported fields
}

func (*UnaryExpr) Pos

func (b *UnaryExpr) Pos() token.Pos

func (*UnaryExpr) RunPass

func (e *UnaryExpr) RunPass(ctx *Context, pass Pass)

func (*UnaryExpr) SetPos

func (b *UnaryExpr) SetPos(pos token.Pos)

type UnaryOp

type UnaryOp int
const (
	UnaryOpUndefined UnaryOp = iota
	UnaryOpNot
	UnaryOpPlus
	UnaryOpMinus
)

type Unit added in v0.2.0

type Unit struct {
	Meta    ASTs
	Imports ASTs
	Block   *StmtBlock
	// contains filtered or unexported fields
}

func (*Unit) Pos added in v0.2.0

func (b *Unit) Pos() token.Pos

func (*Unit) RunPass added in v0.2.0

func (m *Unit) RunPass(ctx *Context, pass Pass)

func (*Unit) Scope added in v0.2.0

func (m *Unit) Scope() *symbol.Scope

func (*Unit) SetPos added in v0.2.0

func (b *Unit) SetPos(pos token.Pos)

type Value

type Value struct {
	Type   Type
	Number float64
	String string
	Bool   bool
}

type VarDeclStmt

type VarDeclStmt struct {
	Vars       []token.Token
	InitValues Exprs
	// contains filtered or unexported fields
}

func (*VarDeclStmt) Pos

func (b *VarDeclStmt) Pos() token.Pos

func (*VarDeclStmt) RunPass

func (s *VarDeclStmt) RunPass(ctx *Context, pass Pass)

func (*VarDeclStmt) SetPos

func (b *VarDeclStmt) SetPos(pos token.Pos)

type WhileStmt

type WhileStmt struct {
	Predicate Expr
	Block     *StmtBlock
	// contains filtered or unexported fields
}

func (*WhileStmt) EmitBreak

func (s *WhileStmt) EmitBreak(pos token.Pos, e *vm.Emitter)

func (*WhileStmt) EmitContinue

func (s *WhileStmt) EmitContinue(pos token.Pos, e *vm.Emitter)

func (*WhileStmt) Pos

func (b *WhileStmt) Pos() token.Pos

func (*WhileStmt) RunPass

func (s *WhileStmt) RunPass(ctx *Context, pass Pass)

func (*WhileStmt) SetPos

func (b *WhileStmt) SetPos(pos token.Pos)

type YieldStmt

type YieldStmt struct {
	Values Exprs
	// contains filtered or unexported fields
}

func (*YieldStmt) Pos

func (b *YieldStmt) Pos() token.Pos

func (*YieldStmt) RunPass

func (s *YieldStmt) RunPass(ctx *Context, pass Pass)

func (*YieldStmt) SetPos

func (b *YieldStmt) SetPos(pos token.Pos)

type ZeroExpr

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

func (*ZeroExpr) Pos

func (b *ZeroExpr) Pos() token.Pos

func (*ZeroExpr) RunPass

func (e *ZeroExpr) RunPass(ctx *Context, pass Pass)

func (*ZeroExpr) SetPos

func (b *ZeroExpr) SetPos(pos token.Pos)

Jump to

Keyboard shortcuts

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