Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
 public static EvaluableExpression ToEvaluableExpression(this string expr, IParser parser, ReadOnlyParseOption option)
 => (parser ?? Parser.Default).Parse(expr, option);
Ejemplo n.º 4
0
 public static IEvaluator <TState> Compile <TState>(this string expr, ReadOnlyParseOption option, ICompiler compiler = null)
 => Compile <TState>(expr, null, option, compiler);
Ejemplo n.º 5
0
 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);
Ejemplo n.º 6
0
 public static EvaluableExpression ToEvaluableExpression(this string expr, ReadOnlyParseOption option)
 => ToEvaluableExpression(expr, null, option);