ast

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: Apache-2.0, Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ARGUMENTLIST signature for argument list snapshot
	ARGUMENTLIST = "AL"
	// MAPARRAYSELECTOR signature for map array snapshot
	MAPARRAYSELECTOR = "MAS"
	// ASSIGMENT signature for assignment snapshot
	ASSIGMENT = "AS"
	// CONSTANT signature for constant snapshot
	CONSTANT = "C"
	// EXPRESSION signature for expression snapshot
	EXPRESSION = "E"
	// EXPRESSIONATOM signature for expression atom snapshot
	EXPRESSIONATOM = "A"
	// FUNCTIONCALL signature for function call snapshot
	FUNCTIONCALL = "F"
	// RULEENTRY signature for rule entry snapshot
	RULEENTRY = "R"
	// THENEXPRESSION signature for then expression snapshot
	THENEXPRESSION = "TE"
	// THENEXPRESSIONLIST signature for then expression list snapshot
	THENEXPRESSIONLIST = "TEL"
	// THENSCOPE signature for then scope snapshot
	THENSCOPE = "TS"
	// WHENSCOPE signature for when scope snapshot
	WHENSCOPE = "WS"
	// VARIABLE signature for variable snapshot
	VARIABLE = "V"
)
View Source
const (
	// OpMul Multiplication operator
	OpMul int = iota
	// OpDiv Divisioon operator
	OpDiv
	// OpMod Modulus operator
	OpMod
	// OpAdd Addition operator
	OpAdd
	// OpSub Substraction operator
	OpSub
	// OpBitAnd Bitwise And operator
	OpBitAnd
	// OpBitOr Bitwise Or operator
	OpBitOr
	// OpGT Greater Than operator
	OpGT
	// OpLT Lesser Than operator
	OpLT
	// OpGTE Greater Than or Equal operator
	OpGTE
	// OpLTE Lesser Than or Equal operator
	OpLTE
	// OpEq Equals operator
	OpEq
	// OpNEq Not Equals operator
	OpNEq
	// OpAnd Logical And operator
	OpAnd
	// OpOr Logical Or operator
	OpOr
)
View Source
const (
	// TypeArgumentList meta type of ArgumentList
	TypeArgumentList NodeType = iota
	// TypeArrayMapSelector meta type of ArrayMapSelector
	TypeArrayMapSelector
	// TypeAssignment meta type of Assigment
	TypeAssignment
	// TypeExpression meta type of Expression
	TypeExpression
	// TypeConstant meta type of Constant
	TypeConstant
	// TypeExpressionAtom meta type of ExpressionAtom
	TypeExpressionAtom
	// TypeFunctionCall meta type of FunctionCall
	TypeFunctionCall
	// TypeRuleEntry meta type of RuleEntry
	TypeRuleEntry
	// TypeThenExpression meta type of ThenExpression
	TypeThenExpression
	// TypeThenExpressionList meta type of ThenExpressionList
	TypeThenExpressionList
	// TypeThenScope meta type of ThenScope
	TypeThenScope
	// TypeVariable meta type of Variable
	TypeVariable
	// TypeWhenScope meta type of WhenScope
	TypeWhenScope

	// TypeString variable type string label
	TypeString ValueType = iota
	// TypeInteger variable type integer label
	TypeInteger
	// TypeFloat variable type float label
	TypeFloat
	// TypeBoolean variable type boolean label
	TypeBoolean

	// Version will be written to the stream and used for compatibility check
	Version = "1.8"
)

Variables

View Source
var (
	// TotalRead counter to track total byte read
	TotalRead = uint64(0)
	// TotalWrite counter to track total bytes written
	TotalWrite = uint64(0)
	// ReadCount read counter
	ReadCount = 0
	// WriteCount write counter
	WriteCount = 0
)
View Source
var (
	// AstLog is a logrus instance twith default fields for grule
	AstLog = logger.Log.WithFields(logrus.Fields{
		"package": "ast",
	})
)
View Source
var (
	// GrlLogger is the logger that be used from within the rule engine GRL
	GrlLogger = logger.Log.WithFields(logrus.Fields{
		"package": "AST",
		"source":  "GRL",
	})
)

Functions

func ReadBoolFromReader

func ReadBoolFromReader(r io.Reader) (bool, error)

ReadBoolFromReader reads a simple boolean from writer

func ReadFloatFromReader

func ReadFloatFromReader(r io.Reader) (float64, error)

ReadFloatFromReader reads a 64bit float from reader

func ReadIntFromReader

func ReadIntFromReader(r io.Reader) (uint64, error)

ReadIntFromReader read a 64 bit integer from reader.

func ReadStringFromReader

func ReadStringFromReader(r io.Reader) (string, error)

ReadStringFromReader read a string from reader.

func WriteBoolToWriter

func WriteBoolToWriter(w io.Writer, b bool) error

WriteBoolToWriter writes a simple boolean into writer

func WriteFloatToWriter

func WriteFloatToWriter(w io.Writer, f float64) error

WriteFloatToWriter write a 64bit float into writer

func WriteFull

func WriteFull(w io.Writer, bytes []byte) (int, error)

WriteFull will ensure that a byte array is fully written into writer

func WriteIntToWriter

func WriteIntToWriter(w io.Writer, i uint64) error

WriteIntToWriter write a 64 bit integer into writer.

func WriteStringToWriter

func WriteStringToWriter(w io.Writer, s string) error

WriteStringToWriter write a string into writer. the structure is that there's length value written prior writing the actual string.

Types

type ArgumentList

type ArgumentList struct {
	AstID   string
	GrlText string

	Arguments []*Expression
}

ArgumentList stores AST graph for ArgumentList that contains expression.

func NewArgumentList

func NewArgumentList() *ArgumentList

NewArgumentList create a new instance of ArgumentList

func (*ArgumentList) AcceptExpression

func (e *ArgumentList) AcceptExpression(exp *Expression) error

AcceptExpression will accept an expression AST graph into this ast graph

func (*ArgumentList) Clone

func (e *ArgumentList) Clone(cloneTable *pkg.CloneTable) *ArgumentList

Clone will clone this ArgumentList. The new clone will have an identical structure

func (*ArgumentList) Evaluate

func (e *ArgumentList) Evaluate(dataContext IDataContext, memory *WorkingMemory) ([]reflect.Value, error)

Evaluate will evaluate this AST graph for when scope evaluation

func (*ArgumentList) GetAstID

func (e *ArgumentList) GetAstID() string

GetAstID get the UUID asigned for this AST graph node

func (*ArgumentList) GetGrlText

func (e *ArgumentList) GetGrlText() string

GetGrlText get the expression syntax related to this graph when it wast constructed

func (*ArgumentList) GetSnapshot

func (e *ArgumentList) GetSnapshot() string

GetSnapshot will create a structure signature or AST graph

func (*ArgumentList) MakeCatalog

func (e *ArgumentList) MakeCatalog(cat *Catalog)

MakeCatalog will create a catalog entry from ArgumentList node.

func (*ArgumentList) SetGrlText

func (e *ArgumentList) SetGrlText(grlText string)

SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.

type ArgumentListMeta

type ArgumentListMeta struct {
	NodeMeta
	ArgumentASTIDs []string
}

ArgumentListMeta meta data for an ArgumentList node

func (*ArgumentListMeta) Equals

func (meta *ArgumentListMeta) Equals(that Meta) bool

Equals basic function to test equality of two MetaNode

func (*ArgumentListMeta) GetASTType

func (meta *ArgumentListMeta) GetASTType() NodeType

GetASTType returns the meta type of this AST Node

func (*ArgumentListMeta) ReadMetaFrom

func (meta *ArgumentListMeta) ReadMetaFrom(r io.Reader) error

ReadMetaFrom write basic AST Node information meta data from reader. One should not use this function directly, unless for testing serialization of single ASTNode.

func (*ArgumentListMeta) WriteMetaTo

func (meta *ArgumentListMeta) WriteMetaTo(w io.Writer) error

WriteMetaTo write basic AST Node information meta data into writer. One should not use this function directly, unless for testing serialization of single ASTNode.

type ArgumentListReceiver

type ArgumentListReceiver interface {
	AcceptArgumentList(argList *ArgumentList) error
}

ArgumentListReceiver will accept an ArgumentList AST graph into this ast graph

type ArrayMapSelector

type ArrayMapSelector struct {
	AstID   string
	GrlText string

	Expression *Expression

	Value reflect.Value
}

ArrayMapSelector an array selector graph containing an expression that act ass array or map selector

func NewArrayMapSelector

func NewArrayMapSelector() *ArrayMapSelector

NewArrayMapSelector create a new array selector graph

func (*ArrayMapSelector) AcceptExpression

func (e *ArrayMapSelector) AcceptExpression(exp *Expression) error

AcceptExpression will accept Expression AST graph node into this node

func (*ArrayMapSelector) Clone

func (e *ArrayMapSelector) Clone(cloneTable *pkg.CloneTable) *ArrayMapSelector

Clone will clone this ArgumentList. The new clone will have an identical structure

func (*ArrayMapSelector) Evaluate

func (e *ArrayMapSelector) Evaluate(dataContext IDataContext, memory *WorkingMemory) (reflect.Value, error)

Evaluate will evaluate this AST graph for when scope evaluation

func (*ArrayMapSelector) GetAstID

func (e *ArrayMapSelector) GetAstID() string

GetAstID get the UUID asigned for this AST graph node

func (*ArrayMapSelector) GetGrlText

func (e *ArrayMapSelector) GetGrlText() string

GetGrlText get the expression syntax related to this graph when it wast constructed

func (*ArrayMapSelector) GetSnapshot

func (e *ArrayMapSelector) GetSnapshot() string

GetSnapshot will create a structure signature or AST graph

func (*ArrayMapSelector) MakeCatalog

func (e *ArrayMapSelector) MakeCatalog(cat *Catalog)

MakeCatalog will create a catalog entry from ArrayMapSelector node.

func (*ArrayMapSelector) SetGrlText

func (e *ArrayMapSelector) SetGrlText(grlText string)

SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.

type ArrayMapSelectorMeta

type ArrayMapSelectorMeta struct {
	NodeMeta
	ExpressionID string
}

ArrayMapSelectorMeta meta data for an ArrayMapSelector node

func (*ArrayMapSelectorMeta) Equals

func (meta *ArrayMapSelectorMeta) Equals(that Meta) bool

Equals basic function to test equality of two MetaNode

func (*ArrayMapSelectorMeta) GetASTType

func (meta *ArrayMapSelectorMeta) GetASTType() NodeType

GetASTType returns the meta type of this AST Node

func (*ArrayMapSelectorMeta) ReadMetaFrom

func (meta *ArrayMapSelectorMeta) ReadMetaFrom(r io.Reader) error

ReadMetaFrom write basic AST Node information meta data from reader. One should not use this function directly, unless for testing serialization of single ASTNode.

func (*ArrayMapSelectorMeta) WriteMetaTo

func (meta *ArrayMapSelectorMeta) WriteMetaTo(w io.Writer) error

WriteMetaTo write basic AST Node information meta data into writer. One should not use this function directly, unless for testing serialization of single ASTNode.

type ArrayMapSelectorReceiver

type ArrayMapSelectorReceiver interface {
	AcceptArrayMapSelector(sel *ArrayMapSelector) error
}

ArrayMapSelectorReceiver must be implemented by all other ast graph that uses map/array selector

type AssigmentMeta

type AssigmentMeta struct {
	NodeMeta
	VariableID    string
	ExpressionID  string
	IsAssign      bool
	IsPlusAssign  bool
	IsMinusAssign bool
	IsDivAssign   bool
	IsMulAssign   bool
}

AssigmentMeta meta data for an Assigment node

func (*AssigmentMeta) Equals

func (meta *AssigmentMeta) Equals(that Meta) bool

Equals basic function to test equality of two MetaNode

func (*AssigmentMeta) GetASTType

func (meta *AssigmentMeta) GetASTType() NodeType

GetASTType returns the meta type of this AST Node

func (*AssigmentMeta) ReadMetaFrom

func (meta *AssigmentMeta) ReadMetaFrom(r io.Reader) error

ReadMetaFrom write basic AST Node information meta data from reader. One should not use this function directly, unless for testing serialization of single ASTNode.

func (*AssigmentMeta) WriteMetaTo

func (meta *AssigmentMeta) WriteMetaTo(w io.Writer) error

WriteMetaTo write basic AST Node information meta data into writer. One should not use this function directly, unless for testing serialization of single ASTNode.

type Assignment

type Assignment struct {
	AstID   string
	GrlText string

	Variable      *Variable
	Expression    *Expression
	IsAssign      bool
	IsPlusAssign  bool
	IsMinusAssign bool
	IsDivAssign   bool
	IsMulAssign   bool
}

Assignment ast node to store assigment expression.

func NewAssignment

func NewAssignment() *Assignment

NewAssignment will create new instance of Assignment AST Node

func (*Assignment) AcceptExpression

func (e *Assignment) AcceptExpression(exp *Expression) error

AcceptExpression will accept an Expression AST graph into this ast graph

func (*Assignment) AcceptVariable

func (e *Assignment) AcceptVariable(vari *Variable) error

AcceptVariable will accept an Variable AST graph into this ast graph

func (*Assignment) Clone

func (e *Assignment) Clone(cloneTable *pkg.CloneTable) *Assignment

Clone will clone this Assignment. The new clone will have an identical structure

func (*Assignment) Execute

func (e *Assignment) Execute(dataContext IDataContext, memory *WorkingMemory) error

Execute will execute this graph in the Then scope

func (*Assignment) GetAstID

func (e *Assignment) GetAstID() string

GetAstID get the UUID asigned for this AST graph node

func (*Assignment) GetGrlText

func (e *Assignment) GetGrlText() string

GetGrlText get the expression syntax related to this graph when it wast constructed

func (*Assignment) GetSnapshot

func (e *Assignment) GetSnapshot() string

GetSnapshot will create a structure signature or AST graph

func (*Assignment) MakeCatalog

func (e *Assignment) MakeCatalog(cat *Catalog)

MakeCatalog will create a catalog entry from Assignment node.

func (*Assignment) SetGrlText

func (e *Assignment) SetGrlText(grlText string)

SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.

type AssignmentReceiver

type AssignmentReceiver interface {
	AcceptAssignment(assignment *Assignment) error
}

AssignmentReceiver must be implemented by all other ast graph that uses an assigment expression

type BooleanLiteral

type BooleanLiteral struct {
	Boolean bool
}

BooleanLiteral will hold BooleanLiteral constant AST data

type BooleanLiteralReceiver

type BooleanLiteralReceiver interface {
	AcceptBooleanLiteral(fun *BooleanLiteral)
}

BooleanLiteralReceiver should be implemented by AST graph node to receive a BooleanLiteral AST graph node

type BuiltInFunctions

type BuiltInFunctions struct {
	Knowledge     *KnowledgeBase
	WorkingMemory *WorkingMemory
	DataContext   IDataContext
}

BuiltInFunctions struct hosts the built-in functions ready to invoke from the rule engine execution.

func (*BuiltInFunctions) Abs

func (gf *BuiltInFunctions) Abs(x float64) float64

Abs is a wrapper function for math.Abs function

func (*BuiltInFunctions) Acos

func (gf *BuiltInFunctions) Acos(x float64) float64

Acos is a wrapper function for math.Acos function

func (*BuiltInFunctions) Acosh

func (gf *BuiltInFunctions) Acosh(x float64) float64

Acosh is a wrapper function for math.Acosh function

func (*BuiltInFunctions) Asin

func (gf *BuiltInFunctions) Asin(x float64) float64

Asin is a wrapper function for math.Asin function

func (*BuiltInFunctions) Asinh

func (gf *BuiltInFunctions) Asinh(x float64) float64

Asinh is a wrapper function for math.Asinh function

func (*BuiltInFunctions) Atan

func (gf *BuiltInFunctions) Atan(x float64) float64

Atan is a wrapper function for math.Atan function

func (*BuiltInFunctions) Atan2

func (gf *BuiltInFunctions) Atan2(y, x float64) float64

Atan2 is a wrapper function for math.Atan2 function

func (*BuiltInFunctions) Atanh

func (gf *BuiltInFunctions) Atanh(x float64) float64

Atanh is a wrapper function for math.Atanh function

func (*BuiltInFunctions) Cbrt

func (gf *BuiltInFunctions) Cbrt(x float64) float64

Cbrt is a wrapper function for math.Cbrt function

func (*BuiltInFunctions) Ceil

func (gf *BuiltInFunctions) Ceil(x float64) float64

Ceil is a wrapper function for math.Ceil function

func (*BuiltInFunctions) Changed

func (gf *BuiltInFunctions) Changed(variableName string)

Changed is another name for Forget function. This function is retained for backward compatibility reason and will be removed in the future.

func (*BuiltInFunctions) Complete

func (gf *BuiltInFunctions) Complete()

Complete will cause the engine to stop processing further rules in the current cycle.

func (*BuiltInFunctions) Copysign

func (gf *BuiltInFunctions) Copysign(x, y float64) float64

Copysign is a wrapper function for math.Copysign function

func (*BuiltInFunctions) Cos

func (gf *BuiltInFunctions) Cos(x float64) float64

Cos is a wrapper function for math.Cos function

func (*BuiltInFunctions) Cosh

func (gf *BuiltInFunctions) Cosh(x float64) float64

Cosh is a wrapper function for math.Cosh function

func (*BuiltInFunctions) Dim

func (gf *BuiltInFunctions) Dim(x, y float64) float64

Dim is a wrapper function for math.Dim function

func (*BuiltInFunctions) Erf

func (gf *BuiltInFunctions) Erf(x float64) float64

Erf is a wrapper function for math.Erf function

func (*BuiltInFunctions) Erfc

func (gf *BuiltInFunctions) Erfc(x float64) float64

Erfc is a wrapper function for math.Erfc function

func (*BuiltInFunctions) Erfcinv

func (gf *BuiltInFunctions) Erfcinv(x float64) float64

Erfcinv is a wrapper function for math.Erfcinv function

func (*BuiltInFunctions) Erfinv

func (gf *BuiltInFunctions) Erfinv(x float64) float64

Erfinv is a wrapper function for math.Erfinv function

func (*BuiltInFunctions) Exp

func (gf *BuiltInFunctions) Exp(x float64) float64

Exp is a wrapper function for math.Exp function

func (*BuiltInFunctions) Exp2

func (gf *BuiltInFunctions) Exp2(x float64) float64

Exp2 is a wrapper function for math.Exp2 function

func (*BuiltInFunctions) Expm1

func (gf *BuiltInFunctions) Expm1(x float64) float64

Expm1 is a wrapper function for math.Expm1 function

func (*BuiltInFunctions) Float64bits

func (gf *BuiltInFunctions) Float64bits(f float64) uint64

Float64bits is a wrapper function for math.Float64bits function

func (*BuiltInFunctions) Float64frombits

func (gf *BuiltInFunctions) Float64frombits(b uint64) float64

Float64frombits is a wrapper function for math.Float64frombits function

func (*BuiltInFunctions) Floor

func (gf *BuiltInFunctions) Floor(x float64) float64

Floor is a wrapper function for math.Floor function

func (*BuiltInFunctions) Forget

func (gf *BuiltInFunctions) Forget(snippet string)

Forget will force Grule's working memory to forget about a variable, or function call, so in the next cycle grue will re-valuate that variable/function instead of just use the value from its working memory. If you change the variable from within grule GRL (using assignment expression, you dont need to call this function on that variable since grule will automaticaly see the change. So only call this function if the variable got changed from your internal struct logic.

func (*BuiltInFunctions) Gamma

func (gf *BuiltInFunctions) Gamma(x float64) float64

Gamma is a wrapper function for math.Gamma function

func (*BuiltInFunctions) GetTimeDay

func (gf *BuiltInFunctions) GetTimeDay(time time.Time) int

GetTimeDay will get the day value of time

func (*BuiltInFunctions) GetTimeHour

func (gf *BuiltInFunctions) GetTimeHour(time time.Time) int

GetTimeHour will get the hour value of time

func (*BuiltInFunctions) GetTimeMinute

func (gf *BuiltInFunctions) GetTimeMinute(time time.Time) int

GetTimeMinute will get the minute value of time

func (*BuiltInFunctions) GetTimeMonth

func (gf *BuiltInFunctions) GetTimeMonth(time time.Time) int

GetTimeMonth will get the month value of time

func (*BuiltInFunctions) GetTimeSecond

func (gf *BuiltInFunctions) GetTimeSecond(time time.Time) int

GetTimeSecond will get the second value of time

func (*BuiltInFunctions) GetTimeYear

func (gf *BuiltInFunctions) GetTimeYear(time time.Time) int

GetTimeYear will get the year value of time

func (*BuiltInFunctions) Hypot

func (gf *BuiltInFunctions) Hypot(p, q float64) float64

Hypot is a wrapper function for math.Hypot function

func (*BuiltInFunctions) Ilogb

func (gf *BuiltInFunctions) Ilogb(x float64) int

Ilogb is a wrapper function for math.Ilogb function

func (*BuiltInFunctions) IsInf

func (gf *BuiltInFunctions) IsInf(f float64, sign int64) bool

IsInf is a wrapper function for math.IsInf function

func (*BuiltInFunctions) IsNaN

func (gf *BuiltInFunctions) IsNaN(f float64) (is bool)

IsNaN is a wrapper function for math.IsNaN function

func (*BuiltInFunctions) IsNil

func (gf *BuiltInFunctions) IsNil(i interface{}) bool

IsNil Enables nill checking on variables.

func (*BuiltInFunctions) IsTimeAfter

func (gf *BuiltInFunctions) IsTimeAfter(time, after time.Time) bool

IsTimeAfter will check if the 1st argument is after the 2nd argument.

func (*BuiltInFunctions) IsTimeBefore

func (gf *BuiltInFunctions) IsTimeBefore(time, before time.Time) bool

IsTimeBefore will check if the 1st argument is before the 2nd argument.

func (*BuiltInFunctions) IsZero

func (gf *BuiltInFunctions) IsZero(i interface{}) bool

IsZero Enable zero checking

func (*BuiltInFunctions) J0

func (gf *BuiltInFunctions) J0(x float64) float64

J0 is a wrapper function for math.J0 function

func (*BuiltInFunctions) J1

func (gf *BuiltInFunctions) J1(x float64) float64

J1 is a wrapper function for math.J1 function

func (*BuiltInFunctions) Jn

func (gf *BuiltInFunctions) Jn(n int64, x float64) float64

Jn is a wrapper function for math.Jn function

func (*BuiltInFunctions) Ldexp

func (gf *BuiltInFunctions) Ldexp(frac float64, exp int64) float64

Ldexp is a wrapper function for math.Ldexp function

func (*BuiltInFunctions) Log

func (gf *BuiltInFunctions) Log(text string)

Log extension to log.Print

func (*BuiltInFunctions) Log10

func (gf *BuiltInFunctions) Log10(x float64) float64

Log10 is a wrapper function for math.Log10 function

func (*BuiltInFunctions) Log1p

func (gf *BuiltInFunctions) Log1p(x float64) float64

Log1p is a wrapper function for math.Log1p function

func (*BuiltInFunctions) Log2

func (gf *BuiltInFunctions) Log2(x float64) float64

Log2 is a wrapper function for math.Log2 function

func (*BuiltInFunctions) LogFormat

func (gf *BuiltInFunctions) LogFormat(format string, i interface{})

LogFormat extension to log.Printf

func (*BuiltInFunctions) Logb

func (gf *BuiltInFunctions) Logb(x float64) float64

Logb is a wrapper function for math.Logb function

func (*BuiltInFunctions) MakeTime

func (gf *BuiltInFunctions) MakeTime(year, month, day, hour, minute, second int64) time.Time

MakeTime will create a Time struct according to the argument values.

func (*BuiltInFunctions) MathLog

func (gf *BuiltInFunctions) MathLog(x float64) float64

MathLog is a wrapper function for math.MathLog function

func (*BuiltInFunctions) Max

func (gf *BuiltInFunctions) Max(vals ...float64) float64

Max will pick the biggest of value in the arguments

func (*BuiltInFunctions) Min

func (gf *BuiltInFunctions) Min(vals ...float64) float64

Min will pick the smallest of value in the arguments

func (*BuiltInFunctions) Mod

func (gf *BuiltInFunctions) Mod(x, y float64) float64

Mod is a wrapper function for math.Mod function

func (*BuiltInFunctions) NaN

func (gf *BuiltInFunctions) NaN() float64

NaN is a wrapper function for math.NaN function

func (*BuiltInFunctions) Now

func (gf *BuiltInFunctions) Now() time.Time

Now is an extension tn time.Now().

func (*BuiltInFunctions) Pow

func (gf *BuiltInFunctions) Pow(x, y float64) float64

Pow is a wrapper function for math.Pow function

func (*BuiltInFunctions) Pow10

func (gf *BuiltInFunctions) Pow10(n int64) float64

Pow10 is a wrapper function for math.Pow10 function

func (*BuiltInFunctions) Remainder

func (gf *BuiltInFunctions) Remainder(x, y float64) float64

Remainder is a wrapper function for math.Remainder function

func (*BuiltInFunctions) Retract

func (gf *BuiltInFunctions) Retract(ruleName string)

Retract will retract a rule from next evaluation cycle.

func (*BuiltInFunctions) Round

func (gf *BuiltInFunctions) Round(x float64) float64

Round is a wrapper function for math.Round function

func (*BuiltInFunctions) RoundToEven

func (gf *BuiltInFunctions) RoundToEven(x float64) float64

RoundToEven is a wrapper function for math.RoundToEven function

func (*BuiltInFunctions) Signbit

func (gf *BuiltInFunctions) Signbit(x float64) bool

Signbit is a wrapper function for math.Signbit function

func (*BuiltInFunctions) Sin

func (gf *BuiltInFunctions) Sin(x float64) float64

Sin is a wrapper function for math.Sin function

func (*BuiltInFunctions) Sinh

func (gf *BuiltInFunctions) Sinh(x float64) float64

Sinh is a wrapper function for math.Sinh function

func (*BuiltInFunctions) Sqrt

func (gf *BuiltInFunctions) Sqrt(x float64) float64

Sqrt is a wrapper function for math.Sqrt function

func (*BuiltInFunctions) StringContains

func (gf *BuiltInFunctions) StringContains(str, substr string) bool

StringContains extension to strings.Contains

func (*BuiltInFunctions) Tan

func (gf *BuiltInFunctions) Tan(x float64) float64

Tan is a wrapper function for math.Tan function

func (*BuiltInFunctions) Tanh

func (gf *BuiltInFunctions) Tanh(x float64) float64

Tanh is a wrapper function for math.Tanh function

func (*BuiltInFunctions) TimeFormat

func (gf *BuiltInFunctions) TimeFormat(time time.Time, layout string) string

TimeFormat will format a time according to format layout.

func (*BuiltInFunctions) Trunc

func (gf *BuiltInFunctions) Trunc(x float64) float64

Trunc is a wrapper function for math.Trunc function

type Catalog

type Catalog struct {
	KnowledgeBaseName               string
	KnowledgeBaseVersion            string
	Data                            map[string]Meta
	MemoryName                      string
	MemoryVersion                   string
	MemoryVariableSnapshotMap       map[string]string
	MemoryExpressionSnapshotMap     map[string]string
	MemoryExpressionAtomSnapshotMap map[string]string
	MemoryExpressionVariableMap     map[string][]string
	MemoryExpressionAtomVariableMap map[string][]string
}

Catalog used to catalog all AST nodes in a KnowledgeBase. All nodes will be saved as their Meta information. which includes relations between AST Node. As RETE algorithm is a prominent aspect of the KnowledgeBase, retaining RETE network is very important. The catalog provides simple recording of Expression, ExpressionAtoms, Variables that capable of supporting the network, enabling the network to be saved and reloaded to/from a stream.

This capability alone supposed to store and load huge ruleset fast without having to read the rule set from their origin GRL which some how a bit expensive due to string parsing and pattern operation by ANTLR4

func (*Catalog) AddMeta

func (cat *Catalog) AddMeta(astID string, meta Meta) bool

AddMeta will add AST Node meta information. it will reject duplicated AST ID

func (*Catalog) BuildKnowledgeBase

func (cat *Catalog) BuildKnowledgeBase() *KnowledgeBase

BuildKnowledgeBase will rebuild a knowledgebase from this Catalog. the rebuilt KnowledgeBase is identical to the original KnowledgeBase from which this Catalog was built.

func (*Catalog) Equals

func (cat *Catalog) Equals(that *Catalog) bool

Equals used for testing purpose, to ensure that two catalog can be compared straight away. The comparison is Deep comparison.

func (*Catalog) ReadCatalogFromReader

func (cat *Catalog) ReadCatalogFromReader(r io.Reader) error

ReadCatalogFromReader would read a byte stream from reader It will replace all values already sets in a catalog. You are responsible for closing the reader stream once its done.

func (*Catalog) WriteCatalogToWriter

func (cat *Catalog) WriteCatalogToWriter(w io.Writer) error

WriteCatalogToWriter will store the content of this Catalog into a byte stream using provided writer. You are responsible for closing the writing stream once its done.

type Constant

type Constant struct {
	AstID         string
	GrlText       string
	Snapshot      string
	DataContext   IDataContext
	WorkingMemory *WorkingMemory
	Value         reflect.Value
	IsNil         bool
}

Constant AST node that stores AST graph for Constants

func NewConstant

func NewConstant() *Constant

NewConstant will create new instance of Constant

func (*Constant) AcceptBooleanLiteral

func (e *Constant) AcceptBooleanLiteral(fun *BooleanLiteral)

AcceptBooleanLiteral will accept boolean literal

func (*Constant) AcceptFloatLiteral

func (e *Constant) AcceptFloatLiteral(fun *FloatLiteral)

AcceptFloatLiteral will accept float literal

func (*Constant) AcceptIntegerLiteral

func (e *Constant) AcceptIntegerLiteral(fun *IntegerLiteral)

AcceptIntegerLiteral will accept integer literal

func (*Constant) AcceptStringLiteral

func (e *Constant) AcceptStringLiteral(fun *StringLiteral)

AcceptStringLiteral will accept string literal

func (*Constant) Clone

func (e *Constant) Clone(cloneTable *pkg.CloneTable) *Constant

Clone will clone this Constant. The new clone will have an identical structure

func (*Constant) Evaluate

func (e *Constant) Evaluate(dataContext IDataContext, memory *WorkingMemory) (reflect.Value, error)

Evaluate will evaluate this AST graph for when scope evaluation

func (*Constant) GetAstID

func (e *Constant) GetAstID() string

GetAstID get the UUID asigned for this AST graph node

func (*Constant) GetGrlText

func (e *Constant) GetGrlText() string

GetGrlText get the expression syntax related to this graph when it wast constructed

func (*Constant) GetSnapshot

func (e *Constant) GetSnapshot() string

GetSnapshot will create a structure signature or AST graph

func (*Constant) MakeCatalog

func (e *Constant) MakeCatalog(cat *Catalog)

MakeCatalog will create a catalog entry from Constant node.

func (*Constant) SetGrlText

func (e *Constant) SetGrlText(grlText string)

SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.

type ConstantMeta

type ConstantMeta struct {
	NodeMeta

	ValueType  ValueType
	ValueBytes []byte
	IsNil      bool
}

ConstantMeta meta data for an Constant node

func (*ConstantMeta) Equals

func (meta *ConstantMeta) Equals(that Meta) bool

Equals basic function to test equality of two MetaNode

func (*ConstantMeta) GetASTType

func (meta *ConstantMeta) GetASTType() NodeType

GetASTType returns the meta type of this AST Node

func (*ConstantMeta) ReadMetaFrom

func (meta *ConstantMeta) ReadMetaFrom(r io.Reader) error

ReadMetaFrom write basic AST Node information meta data from reader. One should not use this function directly, unless for testing serialization of single ASTNode.

func (*ConstantMeta) WriteMetaTo

func (meta *ConstantMeta) WriteMetaTo(w io.Writer) error

WriteMetaTo write basic AST Node information meta data into writer. One should not use this function directly, unless for testing serialization of single ASTNode.

type ConstantReceiver

type ConstantReceiver interface {
	AcceptConstant(con *Constant) error
}

ConstantReceiver should be implemented by AST Graph node to receive a Constant Graph Node.

type DataContext

type DataContext struct {
	ObjectStore map[string]model.ValueNode
	// contains filtered or unexported fields
}

DataContext holds all structs instance to be used in rule execution environment.

func (*DataContext) Add

func (ctx *DataContext) Add(key string, obj interface{}) error

Add will add struct instance into rule execution context

func (*DataContext) AddJSON

func (ctx *DataContext) AddJSON(key string, JSON []byte) error

AddJSON will add struct instance into rule execution context

func (*DataContext) Complete

func (ctx *DataContext) Complete()

Complete marks the DataContext as completed, telling the engine to stop processing rules

func (*DataContext) Get

func (ctx *DataContext) Get(key string) model.ValueNode

Get will extract the struct instance

func (*DataContext) HasVariableChange

func (ctx *DataContext) HasVariableChange() bool

HasVariableChange returns true if there are variable changes

func (*DataContext) IncrementVariableChangeCount

func (ctx *DataContext) IncrementVariableChangeCount()

IncrementVariableChangeCount will increment the variable change count

func (*DataContext) IsComplete

func (ctx *DataContext) IsComplete() bool

IsComplete checks whether the DataContext has been completed

func (*DataContext) IsRetracted

func (ctx *DataContext) IsRetracted(key string) bool

IsRetracted checks if a key fact is currently retracted.

func (*DataContext) Reset

func (ctx *DataContext) Reset()

Reset will un-retract all fact, making them available for evaluation and modification.

func (*DataContext) ResetVariableChangeCount

func (ctx *DataContext) ResetVariableChangeCount()

ResetVariableChangeCount will reset the variable change count

func (*DataContext) Retract

func (ctx *DataContext) Retract(key string)

Retract temporary retract a fact from data context, making it unavailable for evaluation or modification.

func (*DataContext) Retracted

func (ctx *DataContext) Retracted() []string

Retracted returns list of retracted key facts.

type Expression

type Expression struct {
	AstID   string
	GrlText string

	LeftExpression   *Expression
	RightExpression  *Expression
	SingleExpression *Expression
	ExpressionAtom   *ExpressionAtom
	Operator         int
	Negated          bool
	Value            reflect.Value

	Evaluated bool
}

Expression AST Graph node

func NewExpression

func NewExpression() *Expression

NewExpression creates new Expression instance

func (*Expression) AcceptExpression

func (e *Expression) AcceptExpression(exp *Expression) error

AcceptExpression will accept an Expression AST graph into this ast graph

func (*Expression) AcceptExpressionAtom

func (e *Expression) AcceptExpressionAtom(atom *ExpressionAtom) error

AcceptExpressionAtom will accept ExpressionAtom into this Expression

func (*Expression) Clone

func (e *Expression) Clone(cloneTable *pkg.CloneTable) *Expression

Clone will clone this Expression. The new clone will have an identical structure

func (*Expression) Evaluate

func (e *Expression) Evaluate(dataContext IDataContext, memory *WorkingMemory) (reflect.Value, error)

Evaluate will evaluate this AST graph for when scope evaluation

func (*Expression) GetAstID

func (e *Expression) GetAstID() string

GetAstID get the UUID asigned for this AST graph node

func (*Expression) GetGrlText

func (e *Expression) GetGrlText() string

GetGrlText get the expression syntax related to this graph when it wast constructed

func (*Expression) GetSnapshot

func (e *Expression) GetSnapshot() string

GetSnapshot will create a structure signature or AST graph

func (*Expression) MakeCatalog

func (e *Expression) MakeCatalog(cat *Catalog)

MakeCatalog will create a catalog entry from Expression node.

func (*Expression) SetGrlText

func (e *Expression) SetGrlText(grlText string)

SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.

type ExpressionAtom

type ExpressionAtom struct {
	AstID   string
	GrlText string

	VariableName     string
	Constant         *Constant
	FunctionCall     *FunctionCall
	Variable         *Variable
	Negated          bool
	ExpressionAtom   *ExpressionAtom
	ArrayMapSelector *ArrayMapSelector

	Value     reflect.Value
	ValueNode model.ValueNode

	Evaluated bool
}

ExpressionAtom AST node graph

func NewExpressionAtom

func NewExpressionAtom() *ExpressionAtom

NewExpressionAtom create new instance of ExpressionAtom

func (*ExpressionAtom) AcceptArrayMapSelector

func (e *ExpressionAtom) AcceptArrayMapSelector(sel *ArrayMapSelector) error

AcceptArrayMapSelector accept an array map selector into this variable graph

func (*ExpressionAtom) AcceptConstant

func (e *ExpressionAtom) AcceptConstant(cons *Constant) error

AcceptConstant will accept a Constant AST graph into this ast graph

func (*ExpressionAtom) AcceptExpressionAtom

func (e *ExpressionAtom) AcceptExpressionAtom(ea *ExpressionAtom) error

AcceptExpressionAtom will accept an ExpressionAtom AST graph into this ast graph

func (*ExpressionAtom) AcceptFunctionCall

func (e *ExpressionAtom) AcceptFunctionCall(fun *FunctionCall) error

AcceptFunctionCall will accept an FunctionCall AST graph into this ast graph

func (*ExpressionAtom) AcceptMemberVariable

func (e *ExpressionAtom) AcceptMemberVariable(name string)

AcceptMemberVariable accept a member variable AST graph into this Variable graph

func (*ExpressionAtom) AcceptVariable

func (e *ExpressionAtom) AcceptVariable(vari *Variable) error

AcceptVariable will accept an Variable AST graph into this ast graph

func (*ExpressionAtom) Clone

func (e *ExpressionAtom) Clone(cloneTable *pkg.CloneTable) *ExpressionAtom

Clone will clone this ExpressionAtom. The new clone will have an identical structure

func (*ExpressionAtom) Evaluate

func (e *ExpressionAtom) Evaluate(dataContext IDataContext, memory *WorkingMemory) (val reflect.Value, err error)

Evaluate will evaluate this AST graph for when scope evaluation

func (*ExpressionAtom) GetAstID

func (e *ExpressionAtom) GetAstID() string

GetAstID get the UUID asigned for this AST graph node

func (*ExpressionAtom) GetGrlText

func (e *ExpressionAtom) GetGrlText() string

GetGrlText get the expression syntax related to this graph when it wast constructed

func (*ExpressionAtom) GetSnapshot

func (e *ExpressionAtom) GetSnapshot() string

GetSnapshot will create a structure signature or AST graph

func (*ExpressionAtom) MakeCatalog

func (e *ExpressionAtom) MakeCatalog(cat *Catalog)

MakeCatalog will create a catalog entry from ExpressionAtom node.

func (*ExpressionAtom) SetGrlText

func (e *ExpressionAtom) SetGrlText(grlText string)

SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.

type ExpressionAtomMeta

type ExpressionAtomMeta struct {
	NodeMeta
	VariableName       string
	ConstantID         string
	FunctionCallID     string
	VariableID         string
	Negated            bool
	ExpressionAtomID   string
	ArrayMapSelectorID string
}

ExpressionAtomMeta meta data for an ExpressionAtom node

func (*ExpressionAtomMeta) Equals

func (meta *ExpressionAtomMeta) Equals(that Meta) bool

Equals basic function to test equality of two MetaNode

func (*ExpressionAtomMeta) GetASTType

func (meta *ExpressionAtomMeta) GetASTType() NodeType

GetASTType returns the meta type of this AST Node

func (*ExpressionAtomMeta) ReadMetaFrom

func (meta *ExpressionAtomMeta) ReadMetaFrom(r io.Reader) error

ReadMetaFrom write basic AST Node information meta data from reader. One should not use this function directly, unless for testing serialization of single ASTNode.

func (*ExpressionAtomMeta) WriteMetaTo

func (meta *ExpressionAtomMeta) WriteMetaTo(w io.Writer) error

WriteMetaTo write basic AST Node information meta data into writer. One should not use this function directly, unless for testing serialization of single ASTNode.

type ExpressionAtomReceiver

type ExpressionAtomReceiver interface {
	AcceptExpressionAtom(exp *ExpressionAtom) error
}

ExpressionAtomReceiver contains function to be implemented by other AST graph to receive an ExpressionAtom AST graph

type ExpressionMeta

type ExpressionMeta struct {
	NodeMeta
	LeftExpressionID   string
	RightExpressionID  string
	SingleExpressionID string
	ExpressionAtomID   string
	Operator           int
	Negated            bool
}

ExpressionMeta meta data for an Expression node

func (*ExpressionMeta) Equals

func (meta *ExpressionMeta) Equals(that Meta) bool

Equals basic function to test equality of two MetaNode

func (*ExpressionMeta) GetASTType

func (meta *ExpressionMeta) GetASTType() NodeType

GetASTType returns the meta type of this AST Node

func (*ExpressionMeta) ReadMetaFrom

func (meta *ExpressionMeta) ReadMetaFrom(r io.Reader) error

ReadMetaFrom write basic AST Node information meta data from reader. One should not use this function directly, unless for testing serialization of single ASTNode.

func (*ExpressionMeta) WriteMetaTo

func (meta *ExpressionMeta) WriteMetaTo(w io.Writer) error

WriteMetaTo write basic AST Node information meta data into writer. One should not use this function directly, unless for testing serialization of single ASTNode.

type ExpressionReceiver

type ExpressionReceiver interface {
	AcceptExpression(exp *Expression) error
}

ExpressionReceiver contains function to be implemented by other AST graph to receive an Expression AST graph

type FloatLiteral

type FloatLiteral struct {
	Float float64
}

FloatLiteral will hold FloatLiteral constant AST data

type FloatLiteralReceiver

type FloatLiteralReceiver interface {
	AcceptFloatLiteral(fun *FloatLiteral)
}

FloatLiteralReceiver should be implemented by AST graph node to receive a FloatLiteral AST graph node

type FunctionCall

type FunctionCall struct {
	AstID   string
	GrlText string

	FunctionName string
	ArgumentList *ArgumentList
	Value        reflect.Value
}

FunctionCall AST graph node

func NewFunctionCall

func NewFunctionCall() *FunctionCall

NewFunctionCall creates new instance of FunctionCall

func (*FunctionCall) AcceptArgumentList

func (e *FunctionCall) AcceptArgumentList(argList *ArgumentList) error

AcceptArgumentList will accept an ArgumentList AST graph into this ast graph

func (*FunctionCall) Clone

func (e *FunctionCall) Clone(cloneTable *pkg.CloneTable) *FunctionCall

Clone will clone this FunctionCall. The new clone will have an identical structure

func (*FunctionCall) EvaluateArgumentList

func (e *FunctionCall) EvaluateArgumentList(dataContext IDataContext, memory *WorkingMemory) ([]reflect.Value, error)

EvaluateArgumentList will evaluate all arguments and ensure it can be passed into function.

func (*FunctionCall) GetAstID

func (e *FunctionCall) GetAstID() string

GetAstID get the UUID asigned for this AST graph node

func (*FunctionCall) GetGrlText

func (e *FunctionCall) GetGrlText() string

GetGrlText get the expression syntax related to this graph when it wast constructed

func (*FunctionCall) GetSnapshot

func (e *FunctionCall) GetSnapshot() string

GetSnapshot will create a structure signature or AST graph

func (*FunctionCall) MakeCatalog

func (e *FunctionCall) MakeCatalog(cat *Catalog)

MakeCatalog will create a catalog entry from FunctionCall node.

func (*FunctionCall) SetGrlText

func (e *FunctionCall) SetGrlText(grlText string)

SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.

type FunctionCallMeta

type FunctionCallMeta struct {
	NodeMeta
	FunctionName   string
	ArgumentListID string
}

FunctionCallMeta meta data for an FunctionCall node

func (*FunctionCallMeta) Equals

func (meta *FunctionCallMeta) Equals(that Meta) bool

Equals basic function to test equality of two MetaNode

func (*FunctionCallMeta) GetASTType

func (meta *FunctionCallMeta) GetASTType() NodeType

GetASTType returns the meta type of this AST Node

func (*FunctionCallMeta) ReadMetaFrom

func (meta *FunctionCallMeta) ReadMetaFrom(r io.Reader) error

ReadMetaFrom write basic AST Node information meta data from reader. One should not use this function directly, unless for testing serialization of single ASTNode.

func (*FunctionCallMeta) WriteMetaTo

func (meta *FunctionCallMeta) WriteMetaTo(w io.Writer) error

WriteMetaTo write basic AST Node information meta data into writer. One should not use this function directly, unless for testing serialization of single ASTNode.

type FunctionCallReceiver

type FunctionCallReceiver interface {
	AcceptFunctionCall(fun *FunctionCall) error
}

FunctionCallReceiver should be implemented bu AST graph node to receive a FunctionCall AST graph mode

type Grl

type Grl struct {
	RuleEntries map[string]*RuleEntry
}

Grl will contains multiple RuleEntries

func NewGrl

func NewGrl() *Grl

NewGrl creates new GRL instance

func (*Grl) ReceiveRuleEntry

func (g *Grl) ReceiveRuleEntry(entry *RuleEntry) error

ReceiveRuleEntry will make this GRL to accept rule entries created by ANTLR walker

type GrlReceiver

type GrlReceiver interface {
	AcceptGrl(grl *Grl) error
}

GrlReceiver is interface for objects that should hold a GRL, will be called by ANTLR walker.

type IDataContext

type IDataContext interface {
	ResetVariableChangeCount()
	IncrementVariableChangeCount()
	HasVariableChange() bool

	Add(key string, obj interface{}) error
	AddJSON(key string, JSON []byte) error
	Get(key string) model.ValueNode

	Retract(key string)
	IsRetracted(key string) bool
	Complete()
	IsComplete() bool
	Retracted() []string
	Reset()
}

IDataContext is the interface for the DataContext struct.

func NewDataContext

func NewDataContext() IDataContext

NewDataContext will create a new DataContext instance

type IntegerLiteral

type IntegerLiteral struct {
	Integer int64
}

IntegerLiteral will hold IntegerLiteral constant AST data

type IntegerLiteralReceiver

type IntegerLiteralReceiver interface {
	AcceptIntegerLiteral(fun *IntegerLiteral)
}

IntegerLiteralReceiver should be implemented by AST graph node to receive a IntegerLiteral AST graph node

type KnowledgeBase

type KnowledgeBase struct {
	Name          string
	Version       string
	DataContext   IDataContext
	WorkingMemory *WorkingMemory
	RuleEntries   map[string]*RuleEntry
	// contains filtered or unexported fields
}

KnowledgeBase is a collection of RuleEntries. It has a name and version.

func (*KnowledgeBase) AddRuleEntry

func (e *KnowledgeBase) AddRuleEntry(entry *RuleEntry) error

AddRuleEntry add ruleentry into this knowledge base. return an error if a rule entry with the same name already exist in this knowledge base.

func (*KnowledgeBase) Clone

func (e *KnowledgeBase) Clone(cloneTable *pkg.CloneTable) *KnowledgeBase

Clone will clone this instance of KnowledgeBase and produce another (structure wise) identical instance.

func (*KnowledgeBase) ContainsRuleEntry

func (e *KnowledgeBase) ContainsRuleEntry(name string) bool

ContainsRuleEntry will check if a rule with such name is already exist in this knowledge base.

func (*KnowledgeBase) GetSnapshot

func (e *KnowledgeBase) GetSnapshot() string

GetSnapshot will create this knowledge base signature

func (*KnowledgeBase) InitializeContext

func (e *KnowledgeBase) InitializeContext(dataCtx IDataContext)

InitializeContext will initialize this AST graph with data context and working memory before running rule on them.

func (*KnowledgeBase) IsIdentical

func (e *KnowledgeBase) IsIdentical(that *KnowledgeBase) bool

IsIdentical will validate if two KnoledgeBase is identical. Used to validate if the origin and clone is identical.

func (*KnowledgeBase) IsRuleRetracted

func (e *KnowledgeBase) IsRuleRetracted(ruleName string) bool

IsRuleRetracted will check if a certain rule denoted by its rule name is currently retracted

func (*KnowledgeBase) MakeCatalog

func (e *KnowledgeBase) MakeCatalog() *Catalog

MakeCatalog will create a catalog entry for all AST Nodes under the KnowledgeBase the catalog can be used to save the knowledge base into a Writer, or to rebuild the KnowledgeBase from it. This function also will catalog the WorkingMemory.

func (*KnowledgeBase) RemoveRuleEntry

func (e *KnowledgeBase) RemoveRuleEntry(name string)

RemoveRuleEntry remove the rule entry with specified name from this knowledge base

func (*KnowledgeBase) Reset

func (e *KnowledgeBase) Reset()

Reset will restore all rule in the knowledge

func (*KnowledgeBase) RetractRule

func (e *KnowledgeBase) RetractRule(ruleName string)

RetractRule will retract the selected rule for execution on the next cycle.

type KnowledgeLibrary

type KnowledgeLibrary struct {
	Library map[string]*KnowledgeBase
}

KnowledgeLibrary is a knowledgebase store.

func NewKnowledgeLibrary

func NewKnowledgeLibrary() *KnowledgeLibrary

NewKnowledgeLibrary create a new instance KnowledgeLibrary

func (*KnowledgeLibrary) GetKnowledgeBase

func (lib *KnowledgeLibrary) GetKnowledgeBase(name, version string) *KnowledgeBase

GetKnowledgeBase will get the actual KnowledgeBase blue print that will be used to create instances. Although this KnowledgeBase blueprint works, It SHOULD NOT be used directly in the engine. You should obtain KnowledgeBase instance by calling NewKnowledgeBaseInstance

func (*KnowledgeLibrary) LoadKnowledgeBaseFromReader

func (lib *KnowledgeLibrary) LoadKnowledgeBaseFromReader(reader io.Reader, overwrite bool) (retKb *KnowledgeBase, retErr error)

LoadKnowledgeBaseFromReader will load the KnowledgeBase stored using StoreKnowledgeBaseToWriter function be it from file, or anywhere. The reader we needed is a plain io.Reader, thus closing the source stream is your responsibility. This should hopefully speedup loading huge ruleset by storing and reading them without having to parse the GRL.

func (*KnowledgeLibrary) NewKnowledgeBaseInstance

func (lib *KnowledgeLibrary) NewKnowledgeBaseInstance(name, version string) *KnowledgeBase

NewKnowledgeBaseInstance will create a new instance based on KnowledgeBase blue print identified by its name and version

func (*KnowledgeLibrary) StoreKnowledgeBaseToWriter

func (lib *KnowledgeLibrary) StoreKnowledgeBaseToWriter(writer io.Writer, name, version string) error

StoreKnowledgeBaseToWriter will store a KnowledgeBase in binary form once store, the binary stream can be read using LoadKnowledgeBaseFromReader function. This should hopefully speedup loading huge ruleset by storing and reading them without having to parse the GRL.

The stored binary file is greatly increased (easily 10x fold) due to lots of generated keys for AST Nodes that was also saved. To overcome this, the use of archive/zip package for Readers and Writers could cut down the binary size quite a lot.

type MemberVariableReceiver

type MemberVariableReceiver interface {
	AcceptMemberVariable(name string)
}

MemberVariableReceiver should be implemented by AST graph node to receive member Variable information.

type Meta

type Meta interface {
	GetASTType() NodeType
	GetAstID() string
	GetGrlText() string
	GetSnapshot() string
	WriteMetaTo(writer io.Writer) error
	ReadMetaFrom(reader io.Reader) error
	Equals(that Meta) bool
}

Meta interface as contract of all AST Node meta information.

type Node

type Node interface {
	GetAstID() string
	GetGrlText() string
	GetSnapshot() string
	SetGrlText(grlText string)
	MakeCatalog(cat *Catalog)
}

Node defines interface to implement by all AST node models

type NodeMeta

type NodeMeta struct {
	AstID    string
	GrlText  string
	Snapshot string
}

NodeMeta is a base struct for all ASTNode meta

func (*NodeMeta) Equals

func (meta *NodeMeta) Equals(that Meta) bool

Equals basic function to test equality of two MetaNode

func (*NodeMeta) GetAstID

func (meta *NodeMeta) GetAstID() string

GetAstID return the node AST ID

func (*NodeMeta) GetGrlText

func (meta *NodeMeta) GetGrlText() string

GetGrlText return the node original GRLText, this might not be needed but useful for debuging future GRL issue

func (*NodeMeta) GetSnapshot

func (meta *NodeMeta) GetSnapshot() string

GetSnapshot return the NodeSnapshot, this might not needed but could be useful for consistency.

func (*NodeMeta) ReadMetaFrom

func (meta *NodeMeta) ReadMetaFrom(reader io.Reader) error

ReadMetaFrom write basic AST Node information meta data from reader. One should not use this function directly, unless for testing serialization of single ASTNode.

func (*NodeMeta) WriteMetaTo

func (meta *NodeMeta) WriteMetaTo(w io.Writer) error

WriteMetaTo write basic AST Node information meta data into writer. One should not use this function directly, unless for testing serialization of single ASTNode.

type NodeType

type NodeType int

NodeType is to label a Meta information within catalog

type RuleEntry

type RuleEntry struct {
	AstID   string
	GrlText string

	RuleName        string
	RuleDescription string
	Salience        int
	WhenScope       *WhenScope
	ThenScope       *ThenScope

	Retracted bool
}

RuleEntry AST graph node

func NewRuleEntry

func NewRuleEntry() *RuleEntry

NewRuleEntry create new instance of RuleEntry

func (*RuleEntry) AcceptSalience

func (e *RuleEntry) AcceptSalience(salience *Salience) error

AcceptSalience will accept salience value

func (*RuleEntry) AcceptThenScope

func (e *RuleEntry) AcceptThenScope(thenScope *ThenScope) error

AcceptThenScope will accept ThenScope AST Graph into this AST Graph

func (*RuleEntry) AcceptWhenScope

func (e *RuleEntry) AcceptWhenScope(when *WhenScope) error

AcceptWhenScope will accept WhenScope AST Graph into this AST Graph

func (*RuleEntry) Clone

func (e *RuleEntry) Clone(cloneTable *pkg.CloneTable) *RuleEntry

Clone will clone this RuleEntry. The new clone will have an identical structure

func (*RuleEntry) Evaluate

func (e *RuleEntry) Evaluate(dataContext IDataContext, memory *WorkingMemory) (bool, error)

Evaluate will evaluate this AST graph for when scope evaluation

func (*RuleEntry) Execute

func (e *RuleEntry) Execute(dataContext IDataContext, memory *WorkingMemory) (err error)

Execute will execute this graph in the Then scope

func (*RuleEntry) GetAstID

func (e *RuleEntry) GetAstID() string

GetAstID get the UUID asigned for this AST graph node

func (*RuleEntry) GetGrlText

func (e *RuleEntry) GetGrlText() string

GetGrlText get the expression syntax related to this graph when it wast constructed

func (*RuleEntry) GetSnapshot

func (e *RuleEntry) GetSnapshot() string

GetSnapshot will create a structure signature or AST graph

func (*RuleEntry) MakeCatalog

func (e *RuleEntry) MakeCatalog(cat *Catalog)

MakeCatalog will create a catalog entry from RuleEntry node.

func (*RuleEntry) SetGrlText

func (e *RuleEntry) SetGrlText(grlText string)

SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.

type RuleEntryMeta

type RuleEntryMeta struct {
	NodeMeta

	RuleName        string
	RuleDescription string
	Salience        int
	WhenScopeID     string
	ThenScopeID     string
}

RuleEntryMeta meta data for an RuleEntry node

func (*RuleEntryMeta) Equals

func (meta *RuleEntryMeta) Equals(that Meta) bool

Equals basic function to test equality of two MetaNode

func (*RuleEntryMeta) GetASTType

func (meta *RuleEntryMeta) GetASTType() NodeType

GetASTType returns the meta type of this AST Node

func (*RuleEntryMeta) ReadMetaFrom

func (meta *RuleEntryMeta) ReadMetaFrom(r io.Reader) error

ReadMetaFrom write basic AST Node information meta data from reader. One should not use this function directly, unless for testing serialization of single ASTNode.

func (*RuleEntryMeta) WriteMetaTo

func (meta *RuleEntryMeta) WriteMetaTo(w io.Writer) error

WriteMetaTo write basic AST Node information meta data into writer. One should not use this function directly, unless for testing serialization of single ASTNode.

type RuleEntryReceiver

type RuleEntryReceiver interface {
	ReceiveRuleEntry(entry *RuleEntry) error
}

RuleEntryReceiver should be implemented by any rule AST object that receive a RuleEntry

type Salience

type Salience struct {
	SalienceValue int
}

Salience is a simple AST object that stores salience

func NewSalience

func NewSalience(val int) *Salience

NewSalience create new Salience AST object

func (*Salience) AcceptIntegerLiteral

func (sal *Salience) AcceptIntegerLiteral(lit *IntegerLiteral)

AcceptIntegerLiteral accept the assigned integer

type SalienceReceiver

type SalienceReceiver interface {
	AcceptSalience(salience *Salience) error
}

SalienceReceiver must be implemented by any AST object that stores salience

type StringLiteral

type StringLiteral struct {
	String string
}

StringLiteral will hold StringLiteral constant AST data

type StringLiteralReceiver

type StringLiteralReceiver interface {
	AcceptStringLiteral(fun *StringLiteral)
}

StringLiteralReceiver should be implemented by AST graph node to receive a StringLiteral AST graph node

type ThenExpression

type ThenExpression struct {
	AstID   string
	GrlText string

	Assignment     *Assignment
	ExpressionAtom *ExpressionAtom
}

ThenExpression AST graph node

func NewThenExpression

func NewThenExpression() *ThenExpression

NewThenExpression create new instance of ThenExpression

func (*ThenExpression) AcceptAssignment

func (e *ThenExpression) AcceptAssignment(assignment *Assignment) error

AcceptAssignment will accept Assignment AST graph into this Then ast graph

func (*ThenExpression) AcceptExpressionAtom

func (e *ThenExpression) AcceptExpressionAtom(exp *ExpressionAtom) error

AcceptExpressionAtom will accept an AcceptExpressionAtom AST graph into this ast graph

func (*ThenExpression) Clone

func (e *ThenExpression) Clone(cloneTable *pkg.CloneTable) *ThenExpression

Clone will clone this ThenExpression. The new clone will have an identical structure

func (*ThenExpression) Execute

func (e *ThenExpression) Execute(dataContext IDataContext, memory *WorkingMemory) error

Execute will execute this graph in the Then scope

func (*ThenExpression) GetAstID

func (e *ThenExpression) GetAstID() string

GetAstID get the UUID asigned for this AST graph node

func (*ThenExpression) GetGrlText

func (e *ThenExpression) GetGrlText() string

GetGrlText get the expression syntax related to this graph when it wast constructed

func (*ThenExpression) GetSnapshot

func (e *ThenExpression) GetSnapshot() string

GetSnapshot will create a structure signature or AST graph

func (*ThenExpression) MakeCatalog

func (e *ThenExpression) MakeCatalog(cat *Catalog)

MakeCatalog create a catalog entry for this AST Node

func (*ThenExpression) SetGrlText

func (e *ThenExpression) SetGrlText(grlText string)

SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.

type ThenExpressionList

type ThenExpressionList struct {
	AstID   string
	GrlText string

	ThenExpressions []*ThenExpression
}

ThenExpressionList AST graph node

func NewThenExpressionList

func NewThenExpressionList() *ThenExpressionList

NewThenExpressionList creates new instance of ThenExpressionList

func (*ThenExpressionList) AcceptThenExpression

func (e *ThenExpressionList) AcceptThenExpression(expr *ThenExpression) error

AcceptThenExpression will accept ThenExpression AST graph into this ExpressionList

func (*ThenExpressionList) Clone

func (e *ThenExpressionList) Clone(cloneTable *pkg.CloneTable) *ThenExpressionList

Clone will clone this ThenExpressionList. The new clone will have an identical structure

func (*ThenExpressionList) Execute

func (e *ThenExpressionList) Execute(dataContext IDataContext, memory *WorkingMemory) error

Execute will execute this graph in the Then scope

func (*ThenExpressionList) GetAstID

func (e *ThenExpressionList) GetAstID() string

GetAstID get the UUID asigned for this AST graph node

func (*ThenExpressionList) GetGrlText

func (e *ThenExpressionList) GetGrlText() string

GetGrlText get the expression syntax related to this graph when it wast constructed

func (*ThenExpressionList) GetSnapshot

func (e *ThenExpressionList) GetSnapshot() string

GetSnapshot will create a structure signature or AST graph

func (*ThenExpressionList) MakeCatalog

func (e *ThenExpressionList) MakeCatalog(cat *Catalog)

MakeCatalog create a catalog entry for this AST Node

func (*ThenExpressionList) SetGrlText

func (e *ThenExpressionList) SetGrlText(grlText string)

SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.

type ThenExpressionListMeta

type ThenExpressionListMeta struct {
	NodeMeta

	ThenExpressionIDs []string
}

ThenExpressionListMeta meta data for an ThenExpressionList node

func (*ThenExpressionListMeta) Equals

func (meta *ThenExpressionListMeta) Equals(that Meta) bool

Equals basic function to test equality of two MetaNode

func (*ThenExpressionListMeta) GetASTType

func (meta *ThenExpressionListMeta) GetASTType() NodeType

GetASTType returns the meta type of this AST Node

func (*ThenExpressionListMeta) ReadMetaFrom

func (meta *ThenExpressionListMeta) ReadMetaFrom(r io.Reader) error

ReadMetaFrom write basic AST Node information meta data from reader. One should not use this function directly, unless for testing serialization of single ASTNode.

func (*ThenExpressionListMeta) WriteMetaTo

func (meta *ThenExpressionListMeta) WriteMetaTo(w io.Writer) error

WriteMetaTo write basic AST Node information meta data into writer. One should not use this function directly, unless for testing serialization of single ASTNode.

type ThenExpressionListReceiver

type ThenExpressionListReceiver interface {
	AcceptThenExpressionList(list *ThenExpressionList) error
}

ThenExpressionListReceiver must be implemented by any AST object that hold a ThenExpression list AST object

type ThenExpressionMeta

type ThenExpressionMeta struct {
	NodeMeta

	AssignmentID     string
	ExpressionAtomID string
}

ThenExpressionMeta meta data for an ThenExpression node

func (*ThenExpressionMeta) Equals

func (meta *ThenExpressionMeta) Equals(that Meta) bool

Equals basic function to test equality of two MetaNode

func (*ThenExpressionMeta) GetASTType

func (meta *ThenExpressionMeta) GetASTType() NodeType

GetASTType returns the meta type of this AST Node

func (*ThenExpressionMeta) ReadMetaFrom

func (meta *ThenExpressionMeta) ReadMetaFrom(r io.Reader) error

ReadMetaFrom write basic AST Node information meta data from reader. One should not use this function directly, unless for testing serialization of single ASTNode.

func (*ThenExpressionMeta) WriteMetaTo

func (meta *ThenExpressionMeta) WriteMetaTo(w io.Writer) error

WriteMetaTo write basic AST Node information meta data into writer. One should not use this function directly, unless for testing serialization of single ASTNode.

type ThenExpressionReceiver

type ThenExpressionReceiver interface {
	AcceptThenExpression(expr *ThenExpression) error
}

ThenExpressionReceiver must be implemented by any AST object that will store a Then expression

type ThenScope

type ThenScope struct {
	AstID   string
	GrlText string

	ThenExpressionList *ThenExpressionList
}

ThenScope AST graph node

func NewThenScope

func NewThenScope() *ThenScope

NewThenScope will create new instance of ThenScope

func (*ThenScope) AcceptThenExpressionList

func (e *ThenScope) AcceptThenExpressionList(list *ThenExpressionList) error

AcceptThenExpressionList will accept ThenExpressionList graph into this ThenScope

func (*ThenScope) Clone

func (e *ThenScope) Clone(cloneTable *pkg.CloneTable) *ThenScope

Clone will clone this ThenScope. The new clone will have an identical structure

func (*ThenScope) Execute

func (e *ThenScope) Execute(dataContext IDataContext, memory *WorkingMemory) error

Execute will execute this graph in the Then scope

func (*ThenScope) GetAstID

func (e *ThenScope) GetAstID() string

GetAstID get the UUID asigned for this AST graph node

func (*ThenScope) GetGrlText

func (e *ThenScope) GetGrlText() string

GetGrlText get the expression syntax related to this graph when it wast constructed

func (*ThenScope) GetSnapshot

func (e *ThenScope) GetSnapshot() string

GetSnapshot will create a structure signature or AST graph

func (*ThenScope) MakeCatalog

func (e *ThenScope) MakeCatalog(cat *Catalog)

MakeCatalog create a catalog entry for this AST Node

func (*ThenScope) SetGrlText

func (e *ThenScope) SetGrlText(grlText string)

SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.

type ThenScopeMeta

type ThenScopeMeta struct {
	NodeMeta
	ThenExpressionListID string
}

ThenScopeMeta meta data for an ThenScope node

func (*ThenScopeMeta) Equals

func (meta *ThenScopeMeta) Equals(that Meta) bool

Equals basic function to test equality of two MetaNode

func (*ThenScopeMeta) GetASTType

func (meta *ThenScopeMeta) GetASTType() NodeType

GetASTType returns the meta type of this AST Node

func (*ThenScopeMeta) ReadMetaFrom

func (meta *ThenScopeMeta) ReadMetaFrom(r io.Reader) error

ReadMetaFrom write basic AST Node information meta data from reader. One should not use this function directly, unless for testing serialization of single ASTNode.

func (*ThenScopeMeta) WriteMetaTo

func (meta *ThenScopeMeta) WriteMetaTo(w io.Writer) error

WriteMetaTo write basic AST Node information meta data into writer. One should not use this function directly, unless for testing serialization of single ASTNode.

type ThenScopeReceiver

type ThenScopeReceiver interface {
	AcceptThenScope(thenScope *ThenScope) error
}

ThenScopeReceiver must be implemented by any AST object that will hold a ThenScope

type ValueType

type ValueType int

ValueType will label the datatype when a constant its saved as binary

type Variable

type Variable struct {
	AstID   string
	GrlText string

	Name             string
	Variable         *Variable
	ArrayMapSelector *ArrayMapSelector

	ValueNode model.ValueNode
	Value     reflect.Value
}

Variable AST graph node

func NewVariable

func NewVariable() *Variable

NewVariable create new instance of Variable

func (*Variable) AcceptArrayMapSelector

func (e *Variable) AcceptArrayMapSelector(sel *ArrayMapSelector) error

AcceptArrayMapSelector accept an array map selector into this variable graph

func (*Variable) AcceptMemberVariable

func (e *Variable) AcceptMemberVariable(name string)

AcceptMemberVariable accept a member variable information into this Variable graph

func (*Variable) AcceptVariable

func (e *Variable) AcceptVariable(vari *Variable) error

AcceptVariable accept a variable AST graph into this Variable graph

func (*Variable) Assign

func (e *Variable) Assign(newVal reflect.Value, dataContext IDataContext, memory *WorkingMemory) error

Assign will assign the specified value to the variable

func (*Variable) Clone

func (e *Variable) Clone(cloneTable *pkg.CloneTable) *Variable

Clone will clone this Variable. The new clone will have an identical structure

func (*Variable) Evaluate

func (e *Variable) Evaluate(dataContext IDataContext, memory *WorkingMemory) (reflect.Value, error)

Evaluate will evaluate this AST graph for when scope evaluation

func (*Variable) GetAstID

func (e *Variable) GetAstID() string

GetAstID get the UUID asigned for this AST graph node

func (*Variable) GetGrlText

func (e *Variable) GetGrlText() string

GetGrlText get the expression syntax related to this graph when it wast constructed

func (*Variable) GetSnapshot

func (e *Variable) GetSnapshot() string

GetSnapshot will create a structure signature or AST graph

func (*Variable) MakeCatalog

func (e *Variable) MakeCatalog(cat *Catalog)

MakeCatalog create a catalog entry for this AST Node

func (*Variable) SetGrlText

func (e *Variable) SetGrlText(grlText string)

SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.

type VariableMeta

type VariableMeta struct {
	NodeMeta

	Name               string
	VariableID         string
	ArrayMapSelectorID string
}

VariableMeta meta data for an Variable node

func (*VariableMeta) Equals

func (meta *VariableMeta) Equals(that Meta) bool

Equals basic function to test equality of two MetaNode

func (*VariableMeta) GetASTType

func (meta *VariableMeta) GetASTType() NodeType

GetASTType returns the meta type of this AST Node

func (*VariableMeta) ReadMetaFrom

func (meta *VariableMeta) ReadMetaFrom(r io.Reader) error

ReadMetaFrom write basic AST Node information meta data from reader. One should not use this function directly, unless for testing serialization of single ASTNode.

func (*VariableMeta) WriteMetaTo

func (meta *VariableMeta) WriteMetaTo(w io.Writer) error

WriteMetaTo write basic AST Node information meta data into writer. One should not use this function directly, unless for testing serialization of single ASTNode.

type VariableReceiver

type VariableReceiver interface {
	AcceptVariable(exp *Variable) error
}

VariableReceiver should be implemented by AST graph node to receive Variable AST graph node

type WhenScope

type WhenScope struct {
	AstID   string
	GrlText string

	Expression *Expression
}

WhenScope AST graph node

func NewWhenScope

func NewWhenScope() *WhenScope

NewWhenScope creates new instance of WhenScope

func (*WhenScope) AcceptExpression

func (e *WhenScope) AcceptExpression(exp *Expression) error

AcceptExpression will accept Expression AST graph node into this node

func (*WhenScope) Clone

func (e *WhenScope) Clone(cloneTable *pkg.CloneTable) *WhenScope

Clone will clone this Clone. The new clone will have an identical structure

func (*WhenScope) Evaluate

func (e *WhenScope) Evaluate(dataContext IDataContext, memory *WorkingMemory) (reflect.Value, error)

Evaluate will evaluate this AST graph for when scope evaluation

func (*WhenScope) GetAstID

func (e *WhenScope) GetAstID() string

GetAstID get the UUID asigned for this AST graph node

func (*WhenScope) GetGrlText

func (e *WhenScope) GetGrlText() string

GetGrlText get the expression syntax related to this graph when it wast constructed

func (*WhenScope) GetSnapshot

func (e *WhenScope) GetSnapshot() string

GetSnapshot will create a structure signature or AST graph

func (*WhenScope) MakeCatalog

func (e *WhenScope) MakeCatalog(cat *Catalog)

MakeCatalog create a catalog entry for this AST Node

func (*WhenScope) SetGrlText

func (e *WhenScope) SetGrlText(grlText string)

SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.

type WhenScopeMeta

type WhenScopeMeta struct {
	NodeMeta
	ExpressionID string
}

WhenScopeMeta meta data for an WhenScope node

func (*WhenScopeMeta) Equals

func (meta *WhenScopeMeta) Equals(that Meta) bool

Equals basic function to test equality of two MetaNode

func (*WhenScopeMeta) GetASTType

func (meta *WhenScopeMeta) GetASTType() NodeType

GetASTType returns the meta type of this AST Node

func (*WhenScopeMeta) ReadMetaFrom

func (meta *WhenScopeMeta) ReadMetaFrom(r io.Reader) error

ReadMetaFrom write basic AST Node information meta data from reader. One should not use this function directly, unless for testing serialization of single ASTNode.

func (*WhenScopeMeta) WriteMetaTo

func (meta *WhenScopeMeta) WriteMetaTo(w io.Writer) error

WriteMetaTo write basic AST Node information meta data into writer. One should not use this function directly, unless for testing serialization of single ASTNode.

type WhenScopeReceiver

type WhenScopeReceiver interface {
	AcceptWhenScope(whenScope *WhenScope) error
}

WhenScopeReceiver must be implemented by AST object that stores WhenScope

type WorkingMemory

type WorkingMemory struct {
	Name    string
	Version string

	ID string
	// contains filtered or unexported fields
}

WorkingMemory handles states of expression evaluation status

func NewWorkingMemory

func NewWorkingMemory(name, version string) *WorkingMemory

NewWorkingMemory create new instance of WorkingMemory

func (*WorkingMemory) AddExpression

func (e *WorkingMemory) AddExpression(exp *Expression) *Expression

AddExpression will add expression into its map if the expression signature is unique if the expression is already in its map, it will return one from the map.

func (*WorkingMemory) AddExpressionAtom

func (e *WorkingMemory) AddExpressionAtom(exp *ExpressionAtom) *ExpressionAtom

AddExpressionAtom will add expression atom into its map if the expression signature is unique if the expression is already in its map, it will return one from the map.

func (*WorkingMemory) AddVariable

func (e *WorkingMemory) AddVariable(vari *Variable) *Variable

AddVariable will add variable into its map if the expression signature is unique if the expression is already in its map, it will return one from the map.

func (*WorkingMemory) Clone

func (e *WorkingMemory) Clone(cloneTable *pkg.CloneTable) *WorkingMemory

Clone will clone this WorkingMemory. The new clone will have an identical structure

func (*WorkingMemory) DebugContent

func (e *WorkingMemory) DebugContent()

DebugContent will shows the working memory mapping content

func (*WorkingMemory) Equals

func (e *WorkingMemory) Equals(that *WorkingMemory) bool

Equals shallowly equals check this Working Memory against other working memory

func (*WorkingMemory) IndexVariables

func (e *WorkingMemory) IndexVariables()

IndexVariables will index all expression and expression atoms that contains a speciffic variable name

func (*WorkingMemory) MakeCatalog

func (e *WorkingMemory) MakeCatalog(cat *Catalog)

MakeCatalog create a catalog entry of this working memory

func (*WorkingMemory) Reset

func (e *WorkingMemory) Reset(name string) bool

Reset will reset the evaluated status of a specific variable if its contains a variable name in its signature. Returns true if any expression was reset, false if otherwise

func (*WorkingMemory) ResetAll

func (e *WorkingMemory) ResetAll() bool

ResetAll sets all expression evaluated status to false. Returns true if any expression was reset, false if otherwise

func (*WorkingMemory) ResetVariable

func (e *WorkingMemory) ResetVariable(variable *Variable) bool

ResetVariable will reset the evaluated status of a specific expression if its contains a variable name in its signature. Returns true if any expression was reset, false if otherwise

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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