public ExpressionParser(SourceExpression sourceExpression, ReadOnlyParseOption option) { index = 0; se = sourceExpression; this.option = option; maxUnaryOperatorLength = option.UnaryOperators.Any() ? (from item in option.UnaryOperators select item.Operator.Length).Max(x => x) : 0; maxBinaryOperatorLength = option.BinaryOperators.Any() ? (from item in option.BinaryOperators select item.Operator.Length).Max(x => x) : 0; }
public EvaluableExpression Parse(string expr, ReadOnlyParseOption option = null) { if (string.IsNullOrWhiteSpace(expr)) { throw new ArgumentException($"{nameof(expr)} can not be null, empty, and consists only of white-space"); } var sourceExpression = new SourceExpression(expr); var parser = new ExpressionParser(sourceExpression, option ?? defaultParseOption); var expression = parser.Parse(); return(expression); }
public static EvaluableExpression ToEvaluableExpression(this string expr, IParser parser, ReadOnlyParseOption option) => (parser ?? Parser.Default).Parse(expr, option);
public static IEvaluator <TState> Compile <TState>(this string expr, ReadOnlyParseOption option, ICompiler compiler = null) => Compile <TState>(expr, null, option, compiler);
public static IEvaluator <TState> Compile <TState>(this string expr, IParser parser, ReadOnlyParseOption option, ICompiler compiler = null) => expr.ToEvaluableExpression(parser, option).Compile <TState>(compiler ?? Compiler.Default);
public static EvaluableExpression ToEvaluableExpression(this string expr, ReadOnlyParseOption option) => ToEvaluableExpression(expr, null, option);