Documentation ¶
Index ¶
Constants ¶
View Source
const ( Success = iota ErrRuleEngineFuncArgument ErrRuleEngineUnkonwnFunc ErrRuleEngineRegexMatch ErrRuleEngineNotSupportedVarType ErrRuleEngineSyntaxError ErrRuleEngineDivideByZero ErrRuleEngineUnknownVarName ErrRuleEngineInvalidVarType ErrRuleEngineUnknownOperator ErrRuleEngineNotSupportedOperator ErrRuleEngineInvalidOperation )
View Source
const AND = 57355
View Source
const BOOL = 57352
View Source
const E = `([Ee][+-]?[0-9]+)`
View Source
const ELSE = 57365
View Source
const END = 57363
View Source
const EQ = 57360
View Source
const ERROR = 57362
View Source
const FALSE = 57354
View Source
const FLOAT = 57347
View Source
const FS = `(f|F|l|L)`
View Source
const GE = 57359
View Source
const H = `[a-fA-F0-9]`
View Source
const IDENTIFIER = 57351
View Source
const IDLEFT = 57349
View Source
const IDRIGHT = 57350
View Source
const IF = 57364
View Source
const INTEGER = 57346
View Source
const IS = `((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))`
View Source
const L = `[a-zA-Z_]`
View Source
const LE = 57358
View Source
const NE = 57361
View Source
const NOT = 57357
View Source
const OR = 57356
View Source
const P = `([Pp][+-]?[0-9]+)`
View Source
const STRING = 57348
View Source
const TRUE = 57353
Variables ¶
View Source
var KEY_WORD_LIST = [...]TokenRule{ {AND, "AND"}, {AND, "[A|a]nd"}, {OR, "OR"}, {OR, "[o|O]r"}, {NOT, "[N|n]ot"}, {NOT, "NOT"}, {TRUE, "TRUE"}, {TRUE, "[T|t]rue"}, {FALSE, "FALSE"}, {FALSE, "[F|f]alse"}, {IF, "[I|i]f"}, {IF, "IF"}, {ELSE, "[E|e]lse"}, {ELSE, "ELSE"}, }
View Source
var OPER_VALID_TYPE = map[OPER_TYPE][]ValueType{ OPER_TYPE_MATH: {ValueTypeInteger, ValueTypeFloat}, OPER_TYPE_MOD: {ValueTypeInteger}, OPER_TYPE_MINUS: {ValueTypeInteger, ValueTypeFloat}, OPER_TYPE_RELATION: {ValueTypeInteger, ValueTypeFloat}, OPER_TYPE_EQUAL: {ValueTypeInteger, ValueTypeFloat, ValueTypeBool, ValueTypeString}, OPER_TYPE_LOGIC: {ValueTypeBool}, OPER_TYPE_STRING: {ValueTypeString}, OPER_TYPE_ARGUMENT: {ValueTypeArgs}, OPER_TYPE_REGEX: {ValueTypeString}, }
View Source
var TOKEN_RULE_LIST = [...]TokenRule{ {LE, "<="}, {GE, ">="}, {EQ, "=="}, {NE, "!="}, {AND, "&&"}, {NOT, "!"}, {OR, `\|\|`}, {IDLEFT, "{{"}, {IDRIGHT, "}}"}, {STRING, `\"(\\.|[^\\"\n])*\"`}, {STRING, `\'(\\.|[^\\'\n])*\'`}, {FLOAT, fmt.Sprintf(`[0-9]+%v%v?`, E, FS)}, {FLOAT, fmt.Sprintf(`[0-9]+\.[0-9]+%v?%v?`, E, FS)}, {FLOAT, fmt.Sprintf(`[0-9]+\.[0-9]*%v?%v?`, E, FS)}, {INTEGER, fmt.Sprintf(`0[xX]%v+%v?`, H, IS)}, {INTEGER, fmt.Sprintf(`0[0-7]*%v?`, IS)}, {INTEGER, fmt.Sprintf(`[1-9][0-9]*%v?`, IS)}, {IDENTIFIER, fmt.Sprintf(`%v(%v|[0-9])*`, L, L)}, }
View Source
var VALID_CHAR_SET = map[rune]struct{}{
'(': {},
')': {},
'+': {},
'-': {},
'*': {},
'/': {},
'%': {},
'>': {},
'<': {},
',': {},
'.': {},
}
View Source
var VALUE_TOKEN_TO_VALUE_TYPE = map[int]ValueType{ INTEGER: ValueTypeInteger, FLOAT: ValueTypeFloat, STRING: ValueTypeString, TRUE: ValueTypeBool, FALSE: ValueTypeBool, BOOL: ValueTypeBool, IDENTIFIER: ValueTypeString, }
View Source
var VALUE_TYPE_NAME_DICT = map[ValueType]string{ ValueTypeBool: "bool", ValueTypeFloat: "float", ValueTypeString: "string", ValueTypeInteger: "integer", ValueTypeArgs: "args", }
Functions ¶
This section is empty.
Types ¶
type RuleEngineLex ¶
type RuleEngineLex struct {
// contains filtered or unexported fields
}
func NewRuleEngineLex ¶
func NewRuleEngineLex(str string, params []*Param) (*RuleEngineLex, error)
func (*RuleEngineLex) Error ¶
func (lex *RuleEngineLex) Error(s string)
func (*RuleEngineLex) Lex ¶
func (lex *RuleEngineLex) Lex(lval *ruleEngineSymType) int
type TokenNode ¶
type TokenNode struct { ValueType ValueType Value interface{} }
func (*TokenNode) CheckValue ¶
Click to show internal directories.
Click to hide internal directories.