sfvm

package
v1.3.3-beta6 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SFFrame

type SFFrame struct {
	Text  string
	Codes []*SFI
	// contains filtered or unexported fields
}

func NewSFFrame

func NewSFFrame(vars *omap.OrderedMap[string, ValueOperator], text string, codes []*SFI) *SFFrame

func (*SFFrame) Debug

func (s *SFFrame) Debug(v ...bool) *SFFrame

func (*SFFrame) GetSymbolTable

func (s *SFFrame) GetSymbolTable() *omap.OrderedMap[string, ValueOperator]

func (*SFFrame) ToLeft

func (s *SFFrame) ToLeft() bool

func (*SFFrame) ToRight

func (s *SFFrame) ToRight() bool

type SFI

type SFI struct {
	OpCode   SFVMOpCode
	UnaryInt int
	UnaryStr string
	Desc     string
	Values   []string
}

func (*SFI) String

func (s *SFI) String() string

type SFVMOpCode

type SFVMOpCode int
const (
	OpPass SFVMOpCode = iota

	// OpPushNumber and OpPushString and OpPushBool can push literal into stack
	OpPushNumber
	OpPushString
	OpPushBool
	OpPop

	// OpPushSearchExact can push data from origin
	OpPushSearchExact
	OpPushSearchGlob
	OpPushSearchRegexp

	// handle function call
	OpGetCallArgs
	OpGetMembers

	OpTopDefs
	OpBottomUse

	// ListOperation
	OpListIndex

	// => variable
	OpNewRef
	OpUpdateRef

	/*
		Binary Operator
		Fetch TWO in STACK, calc result, push result into stack
	*/
	OpEq
	OpNotEq
	OpGt
	OpGtEq
	OpLt
	OpLtEq
	OpLogicAnd
	OpLogicOr
	OpLogicBang

	/*
		Unary Operator: Fetch ONE in STACK, calc result, push result into stack
	*/
	OpReMatch
	OpGlobMatch
	OpNot

	OpCheckStackTop
)

type SyntaxFlowVirtualMachine

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

func NewSyntaxFlowVirtualMachine

func NewSyntaxFlowVirtualMachine() *SyntaxFlowVirtualMachine

func (*SyntaxFlowVirtualMachine) Compile

func (s *SyntaxFlowVirtualMachine) Compile(text string) (ret error)

func (*SyntaxFlowVirtualMachine) Debug

func (*SyntaxFlowVirtualMachine) Feed

func (*SyntaxFlowVirtualMachine) ForEachFrame added in v1.3.3

func (s *SyntaxFlowVirtualMachine) ForEachFrame(h func(frame *SFFrame))

func (*SyntaxFlowVirtualMachine) Show added in v1.3.3

func (s *SyntaxFlowVirtualMachine) Show()

type SyntaxFlowVisitor

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

func NewSyntaxFlowVisitor

func NewSyntaxFlowVisitor() *SyntaxFlowVisitor

func (*SyntaxFlowVisitor) CreateFrame

func (v *SyntaxFlowVisitor) CreateFrame(vars *omap.OrderedMap[string, ValueOperator]) *SFFrame

func (*SyntaxFlowVisitor) EmitCheckStackTop

func (y *SyntaxFlowVisitor) EmitCheckStackTop()

func (*SyntaxFlowVisitor) EmitEqual

func (v *SyntaxFlowVisitor) EmitEqual(i any)

func (*SyntaxFlowVisitor) EmitGetMembers

func (v *SyntaxFlowVisitor) EmitGetMembers()

func (*SyntaxFlowVisitor) EmitGetTopDef added in v1.3.3

func (y *SyntaxFlowVisitor) EmitGetTopDef()

func (*SyntaxFlowVisitor) EmitListIndex added in v1.3.3

func (y *SyntaxFlowVisitor) EmitListIndex(i int)

func (*SyntaxFlowVisitor) EmitNewRef

func (y *SyntaxFlowVisitor) EmitNewRef(i string)

func (*SyntaxFlowVisitor) EmitOperator

func (y *SyntaxFlowVisitor) EmitOperator(i string)

func (*SyntaxFlowVisitor) EmitPass added in v1.3.3

func (v *SyntaxFlowVisitor) EmitPass()

func (*SyntaxFlowVisitor) EmitPop

func (y *SyntaxFlowVisitor) EmitPop()

func (*SyntaxFlowVisitor) EmitPushCallArgs added in v1.3.3

func (v *SyntaxFlowVisitor) EmitPushCallArgs(i int)

func (*SyntaxFlowVisitor) EmitPushGlob

func (v *SyntaxFlowVisitor) EmitPushGlob(i string)

func (*SyntaxFlowVisitor) EmitPushLiteral

func (v *SyntaxFlowVisitor) EmitPushLiteral(i any)

func (*SyntaxFlowVisitor) EmitRegexpMatch

func (y *SyntaxFlowVisitor) EmitRegexpMatch(i string)

func (*SyntaxFlowVisitor) EmitSearchExact added in v1.3.3

func (v *SyntaxFlowVisitor) EmitSearchExact(i string)

func (*SyntaxFlowVisitor) EmitSearchGlob added in v1.3.3

func (v *SyntaxFlowVisitor) EmitSearchGlob(i string)

func (*SyntaxFlowVisitor) EmitSearchRegexp added in v1.3.3

func (v *SyntaxFlowVisitor) EmitSearchRegexp(i string)

func (*SyntaxFlowVisitor) EmitUpdate

func (y *SyntaxFlowVisitor) EmitUpdate(i string)

func (*SyntaxFlowVisitor) FormatStringOrGlob

func (y *SyntaxFlowVisitor) FormatStringOrGlob(text string) (string, bool)

func (*SyntaxFlowVisitor) Show

func (v *SyntaxFlowVisitor) Show()

func (*SyntaxFlowVisitor) VisitChainFilter

func (y *SyntaxFlowVisitor) VisitChainFilter(raw sf.IChainFilterContext) interface{}

func (*SyntaxFlowVisitor) VisitConditionExpression

func (y *SyntaxFlowVisitor) VisitConditionExpression(raw sf.IConditionExpressionContext) interface{}

func (*SyntaxFlowVisitor) VisitFilterExpr

func (y *SyntaxFlowVisitor) VisitFilterExpr(raw sf.IFilterExprContext) error

func (*SyntaxFlowVisitor) VisitFilterStatement

func (y *SyntaxFlowVisitor) VisitFilterStatement(raw sf.IFilterStatementContext) interface{}

func (*SyntaxFlowVisitor) VisitFilters

func (y *SyntaxFlowVisitor) VisitFilters(raw sf.IFiltersContext) interface{}

func (*SyntaxFlowVisitor) VisitFlow

func (y *SyntaxFlowVisitor) VisitFlow(raw sf.IFlowContext) interface{}

func (*SyntaxFlowVisitor) VisitNameFilter added in v1.3.3

func (y *SyntaxFlowVisitor) VisitNameFilter(i sf.INameFilterContext) error

func (*SyntaxFlowVisitor) VisitNumberLiteral

func (y *SyntaxFlowVisitor) VisitNumberLiteral(raw sf.INumberLiteralContext) int

func (*SyntaxFlowVisitor) VisitRefVariable

func (y *SyntaxFlowVisitor) VisitRefVariable(raw sf.IRefVariableContext) string

func (*SyntaxFlowVisitor) VisitStringLiteral

func (y *SyntaxFlowVisitor) VisitStringLiteral(raw sf.IStringLiteralContext) (string, bool)

type ValueList added in v1.3.3

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

func (*ValueList) ExactMatch added in v1.3.3

func (v *ValueList) ExactMatch(s string) (bool, ValueOperator, error)

func (ValueList) ForEach added in v1.3.3

func (v ValueList) ForEach(h func(i any))

func (*ValueList) GetCallActualParams added in v1.3.3

func (v *ValueList) GetCallActualParams() (ValueOperator, error)

func (ValueList) GetCalled added in v1.3.3

func (v ValueList) GetCalled() (ValueOperator, error)

func (*ValueList) GetMembers

func (v *ValueList) GetMembers() (ValueOperator, error)

func (*ValueList) GetName

func (v *ValueList) GetName() string

func (*ValueList) GetNames

func (v *ValueList) GetNames() []string

func (*ValueList) GetSyntaxFlowBottomUse added in v1.3.3

func (v *ValueList) GetSyntaxFlowBottomUse() (ValueOperator, error)

func (*ValueList) GetSyntaxFlowTopDef added in v1.3.3

func (v *ValueList) GetSyntaxFlowTopDef() (ValueOperator, error)

func (*ValueList) GlobMatch added in v1.3.3

func (v *ValueList) GlobMatch(s glob.Glob) (bool, ValueOperator, error)

func (*ValueList) IsList added in v1.3.3

func (v *ValueList) IsList() bool

func (*ValueList) IsMap added in v1.3.3

func (v *ValueList) IsMap() bool

func (*ValueList) ListIndex added in v1.3.3

func (v *ValueList) ListIndex(i int) (ValueOperator, error)

func (*ValueList) RegexpMatch added in v1.3.3

func (v *ValueList) RegexpMatch(regexp *regexp.Regexp) (bool, ValueOperator, error)

type ValueOperator added in v1.3.3

type ValueOperator interface {
	GetName() string
	GetNames() []string
	IsMap() bool
	IsList() bool

	// ExactMatch return ops, for OpPushSearchExact
	ExactMatch(string) (bool, ValueOperator, error)
	// GlobMatch return opts, for OpPushSearchGlob
	GlobMatch(glob.Glob) (bool, ValueOperator, error)
	// RegexpMatch for OpPushSearchRegexp
	RegexpMatch(*regexp.Regexp) (bool, ValueOperator, error)

	// GetCallActualParams for OpGetCallArgs
	GetCalled() (ValueOperator, error)
	GetCallActualParams() (ValueOperator, error)

	// GetMembers for list or objct
	GetMembers() (ValueOperator, error)

	// GetTopDef and GetBottomUse is for OpBottomUse
	GetSyntaxFlowTopDef() (ValueOperator, error)
	GetSyntaxFlowBottomUse() (ValueOperator, error)

	// ListIndex for OpListIndex, like a[1] a must be list...
	ListIndex(i int) (ValueOperator, error)
}

func AutoValue added in v1.3.3

func AutoValue(i any) ValueOperator

func MergeValues added in v1.3.3

func MergeValues(values ...ValueOperator) ValueOperator

func NewValues added in v1.3.3

func NewValues(values []ValueOperator) ValueOperator

Jump to

Keyboard shortcuts

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