sfvm

package
v1.3.3-beta10 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigItem

type ConfigItem struct {
	Key            string
	Value          string
	SyntaxFlowRule bool
}

type Glob added in v1.3.3

type Glob interface {
	Match(string) bool
	String() string
}

type GlobEx added in v1.3.3

type GlobEx struct {
	Origin glob.Glob
	Rule   string
}

func (*GlobEx) Match added in v1.3.3

func (g *GlobEx) Match(d string) bool

func (*GlobEx) String added in v1.3.3

func (g *GlobEx) String() string

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
	UnaryBool        bool
	Desc             string
	Values           []string
	SyntaxFlowConfig []*ConfigItem
}

func (*SFI) String

func (s *SFI) String() string

type SFVMOpCode

type SFVMOpCode int
const (
	OpPass SFVMOpCode = iota

	OpPushInput
	OpDuplicate

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

	// OpPushSearchExact can push data from origin
	OpPushSearchExact
	OpPushSearchGlob
	OpPushSearchRegexp

	OpGetCallArgs
	OpGetAllCallArgs

	// use def chain
	OpGetUsers
	OpGetBottomUsers
	OpGetDefs
	OpGetTopDefs

	// 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) EmitDuplicate added in v1.3.3

func (v *SyntaxFlowVisitor) EmitDuplicate()

func (*SyntaxFlowVisitor) EmitEqual

func (v *SyntaxFlowVisitor) EmitEqual(i any)

func (*SyntaxFlowVisitor) EmitGetBottomUsers added in v1.3.3

func (v *SyntaxFlowVisitor) EmitGetBottomUsers()

func (*SyntaxFlowVisitor) EmitGetBottomUsersWithConfig added in v1.3.3

func (v *SyntaxFlowVisitor) EmitGetBottomUsersWithConfig(config []*ConfigItem)

func (*SyntaxFlowVisitor) EmitGetCall added in v1.3.3

func (v *SyntaxFlowVisitor) EmitGetCall()

func (*SyntaxFlowVisitor) EmitGetDefs added in v1.3.3

func (v *SyntaxFlowVisitor) EmitGetDefs()

func (*SyntaxFlowVisitor) EmitGetTopDef added in v1.3.3

func (y *SyntaxFlowVisitor) EmitGetTopDef()

func (*SyntaxFlowVisitor) EmitGetTopDefs added in v1.3.3

func (v *SyntaxFlowVisitor) EmitGetTopDefs()

func (*SyntaxFlowVisitor) EmitGetTopDefsWithConfig added in v1.3.3

func (v *SyntaxFlowVisitor) EmitGetTopDefsWithConfig(config []*ConfigItem)

func (*SyntaxFlowVisitor) EmitGetUsers added in v1.3.3

func (v *SyntaxFlowVisitor) EmitGetUsers()

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) EmitPushAllCallArgs added in v1.3.3

func (v *SyntaxFlowVisitor) EmitPushAllCallArgs()

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) EmitPushInput added in v1.3.3

func (v *SyntaxFlowVisitor) EmitPushInput()

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(isMember bool, i string)

func (*SyntaxFlowVisitor) EmitSearchGlob added in v1.3.3

func (v *SyntaxFlowVisitor) EmitSearchGlob(isMember bool, i string)

func (*SyntaxFlowVisitor) EmitSearchRegexp added in v1.3.3

func (v *SyntaxFlowVisitor) EmitSearchRegexp(isMember bool, 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) VisitActualParam added in v1.3.3

func (y *SyntaxFlowVisitor) VisitActualParam(i sf.IActualParamContext) error

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(isMember bool, i sf.INameFilterContext) error

func (*SyntaxFlowVisitor) VisitNumberLiteral

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

func (*SyntaxFlowVisitor) VisitRecursiveConfig added in v1.3.3

func (v *SyntaxFlowVisitor) VisitRecursiveConfig(i *sf.RecursiveConfigContext) []*ConfigItem

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(isMember bool, s string) (bool, ValueOperator, error)

func (ValueList) ForEach added in v1.3.3

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

func (*ValueList) GetAllCallActualParams added in v1.3.3

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

func (*ValueList) GetCallActualParams added in v1.3.3

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

func (ValueList) GetCalled added in v1.3.3

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

func (*ValueList) GetSyntaxFlowBottomUse added in v1.3.3

func (v *ValueList) GetSyntaxFlowBottomUse(config ...*ConfigItem) (ValueOperator, error)

func (*ValueList) GetSyntaxFlowDef added in v1.3.3

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

func (*ValueList) GetSyntaxFlowTopDef added in v1.3.3

func (v *ValueList) GetSyntaxFlowTopDef(config ...*ConfigItem) (ValueOperator, error)

func (*ValueList) GetSyntaxFlowUse added in v1.3.3

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

func (*ValueList) GlobMatch added in v1.3.3

func (v *ValueList) GlobMatch(isMember bool, s 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(isMember bool, regexp *regexp.Regexp) (bool, ValueOperator, error)

func (*ValueList) String added in v1.3.3

func (v *ValueList) String() string

type ValueOperator added in v1.3.3

type ValueOperator interface {
	String() string
	IsMap() bool
	IsList() bool

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

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

	// GetTopDef and GetBottomUse is for OpBottomUse
	// use and def
	GetSyntaxFlowUse() (ValueOperator, error)
	GetSyntaxFlowDef() (ValueOperator, error)
	// top and bottom
	GetSyntaxFlowTopDef(...*ConfigItem) (ValueOperator, error)
	GetSyntaxFlowBottomUse(...*ConfigItem) (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