Documentation ¶
Index ¶
- Constants
- Variables
- type ArgumentList
- func (e *ArgumentList) AcceptExpression(exp *Expression) error
- func (e *ArgumentList) Clone(cloneTable *pkg.CloneTable) *ArgumentList
- func (e *ArgumentList) Evaluate(dataContext IDataContext, memory *WorkingMemory) ([]reflect.Value, error)
- func (e *ArgumentList) GetAstID() string
- func (e *ArgumentList) GetGrlText() string
- func (e *ArgumentList) GetSnapshot() string
- func (e *ArgumentList) SetGrlText(grlText string)
- type ArgumentListReceiver
- type ArrayMapSelector
- func (e *ArrayMapSelector) AcceptExpression(exp *Expression) error
- func (e *ArrayMapSelector) Clone(cloneTable *pkg.CloneTable) *ArrayMapSelector
- func (e *ArrayMapSelector) Evaluate(dataContext IDataContext, memory *WorkingMemory) (reflect.Value, error)
- func (e *ArrayMapSelector) GetAstID() string
- func (e *ArrayMapSelector) GetGrlText() string
- func (e *ArrayMapSelector) GetSnapshot() string
- func (e *ArrayMapSelector) SetGrlText(grlText string)
- type ArrayMapSelectorReceiver
- type Assignment
- func (e *Assignment) AcceptExpression(exp *Expression) error
- func (e *Assignment) AcceptVariable(vari *Variable) error
- func (e *Assignment) Clone(cloneTable *pkg.CloneTable) *Assignment
- func (e *Assignment) Execute(dataContext IDataContext, memory *WorkingMemory) error
- func (e *Assignment) GetAstID() string
- func (e *Assignment) GetGrlText() string
- func (e *Assignment) GetSnapshot() string
- func (e *Assignment) SetGrlText(grlText string)
- type AssignmentReceiver
- type BooleanLiteral
- type BooleanLiteralReceiver
- type BuiltInFunctions
- func (gf *BuiltInFunctions) Abs(x float64) float64
- func (gf *BuiltInFunctions) Acos(x float64) float64
- func (gf *BuiltInFunctions) Acosh(x float64) float64
- func (gf *BuiltInFunctions) Asin(x float64) float64
- func (gf *BuiltInFunctions) Asinh(x float64) float64
- func (gf *BuiltInFunctions) Atan(x float64) float64
- func (gf *BuiltInFunctions) Atan2(y, x float64) float64
- func (gf *BuiltInFunctions) Atanh(x float64) float64
- func (gf *BuiltInFunctions) Cbrt(x float64) float64
- func (gf *BuiltInFunctions) Ceil(x float64) float64
- func (gf *BuiltInFunctions) Changed(variableName string)
- func (gf *BuiltInFunctions) Complete()
- func (gf *BuiltInFunctions) Copysign(x, y float64) float64
- func (gf *BuiltInFunctions) Cos(x float64) float64
- func (gf *BuiltInFunctions) Cosh(x float64) float64
- func (gf *BuiltInFunctions) Dim(x, y float64) float64
- func (gf *BuiltInFunctions) Erf(x float64) float64
- func (gf *BuiltInFunctions) Erfc(x float64) float64
- func (gf *BuiltInFunctions) Erfcinv(x float64) float64
- func (gf *BuiltInFunctions) Erfinv(x float64) float64
- func (gf *BuiltInFunctions) Exp(x float64) float64
- func (gf *BuiltInFunctions) Exp2(x float64) float64
- func (gf *BuiltInFunctions) Expm1(x float64) float64
- func (gf *BuiltInFunctions) Float64bits(f float64) uint64
- func (gf *BuiltInFunctions) Float64frombits(b uint64) float64
- func (gf *BuiltInFunctions) Floor(x float64) float64
- func (gf *BuiltInFunctions) Forget(snippet string)
- func (gf *BuiltInFunctions) Gamma(x float64) float64
- func (gf *BuiltInFunctions) GetTimeDay(time time.Time) int
- func (gf *BuiltInFunctions) GetTimeHour(time time.Time) int
- func (gf *BuiltInFunctions) GetTimeMinute(time time.Time) int
- func (gf *BuiltInFunctions) GetTimeMonth(time time.Time) int
- func (gf *BuiltInFunctions) GetTimeSecond(time time.Time) int
- func (gf *BuiltInFunctions) GetTimeYear(time time.Time) int
- func (gf *BuiltInFunctions) Hypot(p, q float64) float64
- func (gf *BuiltInFunctions) Ilogb(x float64) int
- func (gf *BuiltInFunctions) IsInf(f float64, sign int64) bool
- func (gf *BuiltInFunctions) IsNaN(f float64) (is bool)
- func (gf *BuiltInFunctions) IsNil(i interface{}) bool
- func (gf *BuiltInFunctions) IsTimeAfter(time, after time.Time) bool
- func (gf *BuiltInFunctions) IsTimeBefore(time, before time.Time) bool
- func (gf *BuiltInFunctions) IsZero(i interface{}) bool
- func (gf *BuiltInFunctions) J0(x float64) float64
- func (gf *BuiltInFunctions) J1(x float64) float64
- func (gf *BuiltInFunctions) Jn(n int64, x float64) float64
- func (gf *BuiltInFunctions) Ldexp(frac float64, exp int64) float64
- func (gf *BuiltInFunctions) Log(text string)
- func (gf *BuiltInFunctions) Log10(x float64) float64
- func (gf *BuiltInFunctions) Log1p(x float64) float64
- func (gf *BuiltInFunctions) Log2(x float64) float64
- func (gf *BuiltInFunctions) LogFormat(format string, i interface{})
- func (gf *BuiltInFunctions) Logb(x float64) float64
- func (gf *BuiltInFunctions) MakeTime(year, month, day, hour, minute, second int64) time.Time
- func (gf *BuiltInFunctions) MathLog(x float64) float64
- func (gf *BuiltInFunctions) Max(vals ...float64) float64
- func (gf *BuiltInFunctions) Min(vals ...float64) float64
- func (gf *BuiltInFunctions) Mod(x, y float64) float64
- func (gf *BuiltInFunctions) NaN() float64
- func (gf *BuiltInFunctions) Now() time.Time
- func (gf *BuiltInFunctions) Pow(x, y float64) float64
- func (gf *BuiltInFunctions) Pow10(n int64) float64
- func (gf *BuiltInFunctions) Remainder(x, y float64) float64
- func (gf *BuiltInFunctions) Retract(ruleName string)
- func (gf *BuiltInFunctions) Round(x float64) float64
- func (gf *BuiltInFunctions) RoundToEven(x float64) float64
- func (gf *BuiltInFunctions) Signbit(x float64) bool
- func (gf *BuiltInFunctions) Sin(x float64) float64
- func (gf *BuiltInFunctions) Sinh(x float64) float64
- func (gf *BuiltInFunctions) Sqrt(x float64) float64
- func (gf *BuiltInFunctions) StringContains(str, substr string) bool
- func (gf *BuiltInFunctions) Tan(x float64) float64
- func (gf *BuiltInFunctions) Tanh(x float64) float64
- func (gf *BuiltInFunctions) TimeFormat(time time.Time, layout string) string
- func (gf *BuiltInFunctions) Trunc(x float64) float64
- type Constant
- func (e *Constant) AcceptBooleanLiteral(fun *BooleanLiteral)
- func (e *Constant) AcceptFloatLiteral(fun *FloatLiteral)
- func (e *Constant) AcceptIntegerLiteral(fun *IntegerLiteral)
- func (e *Constant) AcceptStringLiteral(fun *StringLiteral)
- func (e *Constant) Clone(cloneTable *pkg.CloneTable) *Constant
- func (e *Constant) Evaluate(dataContext IDataContext, memory *WorkingMemory) (reflect.Value, error)
- func (e *Constant) GetAstID() string
- func (e *Constant) GetGrlText() string
- func (e *Constant) GetSnapshot() string
- func (e *Constant) SetGrlText(grlText string)
- type ConstantReceiver
- type DataContext
- func (ctx *DataContext) Add(key string, obj interface{}) error
- func (ctx *DataContext) AddJSON(key string, JSON []byte) error
- func (ctx *DataContext) Complete()
- func (ctx *DataContext) Get(key string) model.ValueNode
- func (ctx *DataContext) HasVariableChange() bool
- func (ctx *DataContext) IncrementVariableChangeCount()
- func (ctx *DataContext) IsComplete() bool
- func (ctx *DataContext) IsRetracted(key string) bool
- func (ctx *DataContext) Reset()
- func (ctx *DataContext) ResetVariableChangeCount()
- func (ctx *DataContext) Retract(key string)
- func (ctx *DataContext) Retracted() []string
- type Expression
- func (e *Expression) AcceptExpression(exp *Expression) error
- func (e *Expression) AcceptExpressionAtom(atom *ExpressionAtom) error
- func (e *Expression) Clone(cloneTable *pkg.CloneTable) *Expression
- func (e *Expression) Evaluate(dataContext IDataContext, memory *WorkingMemory) (reflect.Value, error)
- func (e *Expression) GetAstID() string
- func (e *Expression) GetGrlText() string
- func (e *Expression) GetSnapshot() string
- func (e *Expression) SetGrlText(grlText string)
- type ExpressionAtom
- func (e *ExpressionAtom) AcceptArrayMapSelector(sel *ArrayMapSelector) error
- func (e *ExpressionAtom) AcceptConstant(cons *Constant) error
- func (e *ExpressionAtom) AcceptExpressionAtom(ea *ExpressionAtom) error
- func (e *ExpressionAtom) AcceptFunctionCall(fun *FunctionCall) error
- func (e *ExpressionAtom) AcceptMemberVariable(name string)
- func (e *ExpressionAtom) AcceptVariable(vari *Variable) error
- func (e *ExpressionAtom) Clone(cloneTable *pkg.CloneTable) *ExpressionAtom
- func (e *ExpressionAtom) Evaluate(dataContext IDataContext, memory *WorkingMemory) (val reflect.Value, err error)
- func (e *ExpressionAtom) GetAstID() string
- func (e *ExpressionAtom) GetGrlText() string
- func (e *ExpressionAtom) GetSnapshot() string
- func (e *ExpressionAtom) SetGrlText(grlText string)
- type ExpressionAtomReceiver
- type ExpressionReceiver
- type FloatLiteral
- type FloatLiteralReceiver
- type FunctionCall
- func (e *FunctionCall) AcceptArgumentList(argList *ArgumentList) error
- func (e *FunctionCall) Clone(cloneTable *pkg.CloneTable) *FunctionCall
- func (e *FunctionCall) EvaluateArgumentList(dataContext IDataContext, memory *WorkingMemory) ([]reflect.Value, error)
- func (e *FunctionCall) GetAstID() string
- func (e *FunctionCall) GetGrlText() string
- func (e *FunctionCall) GetSnapshot() string
- func (e *FunctionCall) SetGrlText(grlText string)
- type FunctionCallReceiver
- type Grl
- type GrlReceiver
- type IDataContext
- type IntegerLiteral
- type IntegerLiteralReceiver
- type KnowledgeBase
- func (e *KnowledgeBase) AddRuleEntry(entry *RuleEntry) error
- func (e *KnowledgeBase) Clone(cloneTable *pkg.CloneTable) *KnowledgeBase
- func (e *KnowledgeBase) ContainsRuleEntry(name string) bool
- func (e *KnowledgeBase) GetSnapshot() string
- func (e *KnowledgeBase) InitializeContext(dataCtx IDataContext)
- func (e *KnowledgeBase) IsIdentical(that *KnowledgeBase) bool
- func (e *KnowledgeBase) IsRuleRetracted(ruleName string) bool
- func (e *KnowledgeBase) RemoveRuleEntry(name string)
- func (e *KnowledgeBase) Reset()
- func (e *KnowledgeBase) RetractRule(ruleName string)
- type KnowledgeLibrary
- type MemberVariableReceiver
- type Node
- type RuleEntry
- func (e *RuleEntry) AcceptSalience(salience *Salience) error
- func (e *RuleEntry) AcceptThenScope(thenScope *ThenScope) error
- func (e *RuleEntry) AcceptWhenScope(when *WhenScope) error
- func (e *RuleEntry) Clone(cloneTable *pkg.CloneTable) *RuleEntry
- func (e *RuleEntry) Evaluate(dataContext IDataContext, memory *WorkingMemory) (bool, error)
- func (e *RuleEntry) Execute(dataContext IDataContext, memory *WorkingMemory) (err error)
- func (e *RuleEntry) GetAstID() string
- func (e *RuleEntry) GetGrlText() string
- func (e *RuleEntry) GetSnapshot() string
- func (e *RuleEntry) SetGrlText(grlText string)
- type RuleEntryReceiver
- type Salience
- type SalienceReceiver
- type StringLiteral
- type StringLiteralReceiver
- type ThenExpression
- func (e *ThenExpression) AcceptAssignment(assignment *Assignment) error
- func (e *ThenExpression) AcceptExpressionAtom(exp *ExpressionAtom) error
- func (e *ThenExpression) Clone(cloneTable *pkg.CloneTable) *ThenExpression
- func (e *ThenExpression) Execute(dataContext IDataContext, memory *WorkingMemory) error
- func (e *ThenExpression) GetAstID() string
- func (e *ThenExpression) GetGrlText() string
- func (e *ThenExpression) GetSnapshot() string
- func (e *ThenExpression) SetGrlText(grlText string)
- type ThenExpressionList
- func (e *ThenExpressionList) AcceptThenExpression(expr *ThenExpression) error
- func (e *ThenExpressionList) Clone(cloneTable *pkg.CloneTable) *ThenExpressionList
- func (e *ThenExpressionList) Execute(dataContext IDataContext, memory *WorkingMemory) error
- func (e *ThenExpressionList) GetAstID() string
- func (e *ThenExpressionList) GetGrlText() string
- func (e *ThenExpressionList) GetSnapshot() string
- func (e *ThenExpressionList) SetGrlText(grlText string)
- type ThenExpressionListReceiver
- type ThenExpressionReceiver
- type ThenScope
- func (e *ThenScope) AcceptThenExpressionList(list *ThenExpressionList) error
- func (e *ThenScope) Clone(cloneTable *pkg.CloneTable) *ThenScope
- func (e *ThenScope) Execute(dataContext IDataContext, memory *WorkingMemory) error
- func (e *ThenScope) GetAstID() string
- func (e *ThenScope) GetGrlText() string
- func (e *ThenScope) GetSnapshot() string
- func (e *ThenScope) SetGrlText(grlText string)
- type ThenScopeReceiver
- type Variable
- func (e *Variable) AcceptArrayMapSelector(sel *ArrayMapSelector) error
- func (e *Variable) AcceptMemberVariable(name string)
- func (e *Variable) AcceptVariable(vari *Variable) error
- func (e *Variable) Assign(newVal reflect.Value, dataContext IDataContext, memory *WorkingMemory) error
- func (e *Variable) Clone(cloneTable *pkg.CloneTable) *Variable
- func (e *Variable) Evaluate(dataContext IDataContext, memory *WorkingMemory) (reflect.Value, error)
- func (e *Variable) GetAstID() string
- func (e *Variable) GetGrlText() string
- func (e *Variable) GetSnapshot() string
- func (e *Variable) SetGrlText(grlText string)
- type VariableReceiver
- type WhenScope
- func (e *WhenScope) AcceptExpression(exp *Expression) error
- func (e *WhenScope) Clone(cloneTable *pkg.CloneTable) *WhenScope
- func (e *WhenScope) Evaluate(dataContext IDataContext, memory *WorkingMemory) (reflect.Value, error)
- func (e *WhenScope) GetAstID() string
- func (e *WhenScope) GetGrlText() string
- func (e *WhenScope) GetSnapshot() string
- func (e *WhenScope) SetGrlText(grlText string)
- type WhenScopeReceiver
- type WorkingMemory
- func (e *WorkingMemory) AddExpression(exp *Expression) *Expression
- func (e *WorkingMemory) AddExpressionAtom(exp *ExpressionAtom) *ExpressionAtom
- func (e *WorkingMemory) AddVariable(vari *Variable) *Variable
- func (e *WorkingMemory) Clone(cloneTable *pkg.CloneTable) *WorkingMemory
- func (e *WorkingMemory) DebugContent()
- func (e *WorkingMemory) Equals(that *WorkingMemory) bool
- func (e *WorkingMemory) IndexVariables()
- func (e *WorkingMemory) Reset(name string) bool
- func (e *WorkingMemory) ResetAll() bool
- func (e *WorkingMemory) ResetVariable(variable *Variable) bool
Constants ¶
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" )
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 )
Variables ¶
var ( // AstLog is a logrus instance twith default fields for grule AstLog = logger.Log.WithFields(logrus.Fields{ "package": "ast", }) )
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 ¶
This section is empty.
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) 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 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) 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 ArrayMapSelectorReceiver ¶
type ArrayMapSelectorReceiver interface {
AcceptArrayMapSelector(sel *ArrayMapSelector) error
}
ArrayMapSelectorReceiver must be implemented by all other ast graph that uses map/array selector
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) 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 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 (*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) GetGrlText ¶
GetGrlText get the expression syntax related to this graph when it wast constructed
func (*Constant) GetSnapshot ¶
GetSnapshot will create a structure signature or AST graph
func (*Constant) SetGrlText ¶
SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.
type ConstantReceiver ¶
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 (*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) 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 Value reflect.Value ValueNode model.ValueNode ArrayMapSelector *ArrayMapSelector 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) 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 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 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) 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 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 ¶
Grl will contains multiple RuleEntries
func (*Grl) ReceiveRuleEntry ¶
ReceiveRuleEntry will make this GRL to accept rule entries created by ANTLR walker
type GrlReceiver ¶
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) 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 // contains filtered or unexported fields }
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) 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
type MemberVariableReceiver ¶
type MemberVariableReceiver interface {
AcceptMemberVariable(name string)
}
MemberVariableReceiver should be implemented by AST graph node to receive member Variable information.
type Node ¶
type Node interface { GetAstID() string GetGrlText() string GetSnapshot() string SetGrlText(grlText string) }
Node defines interface to implement by all AST node models
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 (*RuleEntry) AcceptSalience ¶
AcceptSalience will accept salience value
func (*RuleEntry) AcceptThenScope ¶
AcceptThenScope will accept ThenScope AST Graph into this AST Graph
func (*RuleEntry) AcceptWhenScope ¶
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) GetGrlText ¶
GetGrlText get the expression syntax related to this graph when it wast constructed
func (*RuleEntry) GetSnapshot ¶
GetSnapshot will create a structure signature or AST graph
func (*RuleEntry) SetGrlText ¶
SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.
type RuleEntryReceiver ¶
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 (*Salience) AcceptIntegerLiteral ¶
func (sal *Salience) AcceptIntegerLiteral(lit *IntegerLiteral)
AcceptIntegerLiteral accept the assigned integer
type SalienceReceiver ¶
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) 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) 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 ThenExpressionListReceiver ¶
type ThenExpressionListReceiver interface {
AcceptThenExpressionList(list *ThenExpressionList) error
}
ThenExpressionListReceiver must be implemented by any AST object that hold a ThenExpression list AST object
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) GetGrlText ¶
GetGrlText get the expression syntax related to this graph when it wast constructed
func (*ThenScope) GetSnapshot ¶
GetSnapshot will create a structure signature or AST graph
func (*ThenScope) SetGrlText ¶
SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.
type ThenScopeReceiver ¶
ThenScopeReceiver must be implemented by any AST object that will hold a ThenScope
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 (*Variable) AcceptArrayMapSelector ¶
func (e *Variable) AcceptArrayMapSelector(sel *ArrayMapSelector) error
AcceptArrayMapSelector accept an array map selector into this variable graph
func (*Variable) AcceptMemberVariable ¶
AcceptMemberVariable accept a member variable information into this Variable graph
func (*Variable) AcceptVariable ¶
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) GetGrlText ¶
GetGrlText get the expression syntax related to this graph when it wast constructed
func (*Variable) GetSnapshot ¶
GetSnapshot will create a structure signature or AST graph
func (*Variable) SetGrlText ¶
SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.
type VariableReceiver ¶
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 (*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) GetGrlText ¶
GetGrlText get the expression syntax related to this graph when it wast constructed
func (*WhenScope) GetSnapshot ¶
GetSnapshot will create a structure signature or AST graph
func (*WhenScope) SetGrlText ¶
SetGrlText set the expression syntax related to this graph when it was constructed. Only ANTLR4 listener should call this function.
type WhenScopeReceiver ¶
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) 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
Source Files ¶
- ArgumentList.go
- ArrayMapSelector.go
- Assignment.go
- Ast.go
- BuiltInFunctions.go
- Constant.go
- DataContext.go
- Expression.go
- ExpressionAtom.go
- FunctionCall.go
- Grl.go
- KnowledgeBase.go
- Literal.go
- RuleEntry.go
- Salience.go
- ThenExpression.go
- ThenExpressionList.go
- ThenScope.go
- Variable.go
- WhenScope.go
- WorkingMemory.go