sfvm

package
v1.3.0-sp5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteBoolResult

func ExecuteBoolResult(op1, op2 *Value, opcode SFVMOpCode) (bool, error)

Types

type SFFrame

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

func NewSFFrame

func NewSFFrame(vars *omap.OrderedMap[string, any], 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, any]

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
	OpWithdraw

	// OpPushMatch can push data from origin
	OpPushMatch
	// OpPushIndex can push data from index
	OpPushIndex
	// OpPushRef can push reference into stack
	OpPushRef
	// OpNewRef can create new symbol reference
	OpNewRef
	OpUpdateRef

	//
	OpFetchField
	OpFetchIndex
	OpSetDirection
	OpFlatStart
	OpFlatDone
	OpRestoreFlatContext
	OpMapStart
	OpMapDone
	OpRestoreMapContext
	OpTypeCast

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

	/*
		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

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, any]) *SFFrame

func (*SyntaxFlowVisitor) EmitCheckStackTop

func (y *SyntaxFlowVisitor) EmitCheckStackTop()

func (*SyntaxFlowVisitor) EmitDirection

func (v *SyntaxFlowVisitor) EmitDirection(i string)

func (*SyntaxFlowVisitor) EmitEqual

func (v *SyntaxFlowVisitor) EmitEqual(i any)

func (*SyntaxFlowVisitor) EmitFetchIndex

func (y *SyntaxFlowVisitor) EmitFetchIndex(i int)

func (*SyntaxFlowVisitor) EmitField

func (v *SyntaxFlowVisitor) EmitField(i string)

func (*SyntaxFlowVisitor) EmitFlatDone

func (y *SyntaxFlowVisitor) EmitFlatDone(i int)

func (*SyntaxFlowVisitor) EmitFlatStart

func (y *SyntaxFlowVisitor) EmitFlatStart(i int)

func (*SyntaxFlowVisitor) EmitMapBuildDone

func (y *SyntaxFlowVisitor) EmitMapBuildDone(refs ...string)

func (*SyntaxFlowVisitor) EmitMapBuildStart

func (y *SyntaxFlowVisitor) EmitMapBuildStart()

func (*SyntaxFlowVisitor) EmitNewRef

func (y *SyntaxFlowVisitor) EmitNewRef(i string)

func (*SyntaxFlowVisitor) EmitOperator

func (y *SyntaxFlowVisitor) EmitOperator(i string)

func (*SyntaxFlowVisitor) EmitPop

func (y *SyntaxFlowVisitor) EmitPop()

func (*SyntaxFlowVisitor) EmitPushGlob

func (v *SyntaxFlowVisitor) EmitPushGlob(i string)

func (*SyntaxFlowVisitor) EmitPushIndex

func (v *SyntaxFlowVisitor) EmitPushIndex(i int)

func (*SyntaxFlowVisitor) EmitPushLiteral

func (v *SyntaxFlowVisitor) EmitPushLiteral(i any)

func (*SyntaxFlowVisitor) EmitRef

func (v *SyntaxFlowVisitor) EmitRef(i string)

func (*SyntaxFlowVisitor) EmitRegexpMatch

func (y *SyntaxFlowVisitor) EmitRegexpMatch(i string)

func (*SyntaxFlowVisitor) EmitRestoreFlatContext

func (y *SyntaxFlowVisitor) EmitRestoreFlatContext()

func (*SyntaxFlowVisitor) EmitRestoreMapContext

func (y *SyntaxFlowVisitor) EmitRestoreMapContext()

func (*SyntaxFlowVisitor) EmitSearch

func (v *SyntaxFlowVisitor) EmitSearch(i string)

func (*SyntaxFlowVisitor) EmitTypeCast

func (v *SyntaxFlowVisitor) EmitTypeCast(i string)

func (*SyntaxFlowVisitor) EmitUpdate

func (y *SyntaxFlowVisitor) EmitUpdate(i string)

func (*SyntaxFlowVisitor) EmitWithdraw

func (y *SyntaxFlowVisitor) EmitWithdraw()

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) VisitExistedRef

func (y *SyntaxFlowVisitor) VisitExistedRef(raw sf.IExistedRefContext) interface{}

func (*SyntaxFlowVisitor) VisitFilterExpr

func (y *SyntaxFlowVisitor) VisitFilterExpr(raw sf.IFilterExprContext) interface{}

func (*SyntaxFlowVisitor) VisitFilterFieldMember

func (y *SyntaxFlowVisitor) VisitFilterFieldMember(raw sf.IFilterFieldMemberContext) interface{}

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) 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 Value

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

func NewValue

func NewValue(v any) *Value

func (*Value) AsBool

func (v *Value) AsBool() bool

func (*Value) AsInt

func (v *Value) AsInt() int

func (*Value) AsMap

func (v *Value) AsMap() *omap.OrderedMap[string, any]

func (*Value) AsString

func (v *Value) AsString() string

func (*Value) Exec

func (op1 *Value) Exec(i SFVMOpCode, op2 *Value) (*Value, error)

func (*Value) IsMap

func (v *Value) IsMap() bool

func (*Value) Value

func (v *Value) Value() any

func (*Value) VerboseString

func (v *Value) VerboseString() string

Jump to

Keyboard shortcuts

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