protected void RegisterFunction(IFunctionDefinition function) { GuardParams(function); functions.Add(function.Name, function); _functionNameSet.Add(function.Name); _maxKeyLength = TokenizerConfiguration.CalculaterMaxTokenLength(_functionNameSet); }
private void Init() { var operands = new List <string>(); var whiteSpaceOperands = new List <string>(); Register(new AssignmentParser(), operands, whiteSpaceOperands); Register(new BooleanTernaryExpressionParser(), operands, whiteSpaceOperands); Register(new AddParser(), operands, whiteSpaceOperands); Register(new MinusParser(), operands, whiteSpaceOperands); Register(new MultiplyParser(), operands, whiteSpaceOperands); Register(new DivideParser(), operands, whiteSpaceOperands); Register(new ModuloParser(), operands, whiteSpaceOperands); Register(new PowerParser(), operands, whiteSpaceOperands); Register(new ConcatParser(), operands, whiteSpaceOperands); Register(new ConcatWithSpaceParser(), operands, whiteSpaceOperands); Register(new LessThanParser(), operands, whiteSpaceOperands); Register(new GreaterThanParser(), operands, whiteSpaceOperands); Register(new LessThanOrEqualParser(), operands, whiteSpaceOperands); Register(new GreaterThanOrEqualParser(), operands, whiteSpaceOperands); Register(new EqualToParser(), operands, whiteSpaceOperands); Register(new NotEqualToParser(), operands, whiteSpaceOperands); Register(new AndParser(), operands, whiteSpaceOperands); Register(new OrParser(), operands, whiteSpaceOperands); Register(new NotParser(), operands, whiteSpaceOperands); Register(new BracketsParser(), operands, whiteSpaceOperands); Register(new SquareBracketsParser(), operands, whiteSpaceOperands); foreach (var func in new MathFunctionLib().Functions) { Register(new MathFunctionParser(func), operands, whiteSpaceOperands); } Register(new FunctionParser(new BaseFunctionLib()), operands, whiteSpaceOperands); foreach (var lib in _libs) { Register(new FunctionParser(lib), operands, whiteSpaceOperands); } Register(new StringConstantParser(), operands, whiteSpaceOperands); Register(new ConstantParser(), operands, whiteSpaceOperands); if (TRY_RESOLVE_PROPERTY_INTO_CONSTANT) { AddParserByTypes(new PropertyOrConstantParser().ParsedTypes, new PropertyOrConstantParser()); } else { AddParserByTypes(new PropertyParser().ParsedTypes, new PropertyParser()); } OPERANDS = operands.ToArray(); WHITESPACE_OPERANDS = whiteSpaceOperands.ToArray(); WHITESPACE_OPERANDS_SET = new HashSet <string>(WHITESPACE_OPERANDS); WHITESPACE_OPERANDS_SET_MAX_LENGTH = TokenizerConfiguration.CalculaterMaxTokenLength(WHITESPACE_OPERANDS_SET); configuration = new TokenizerConfiguration('\\', OPERANDS, WHITESPACE_OPERANDS, null, true, false); }