Пример #1
0
        void ParseSimple(string expression, IExpressionOutput <T> output)
        {
            if (this.parser == null)
            {
                this.parser = new Parser <T>(this);
            }

            this.parser.Parse(expression, output);
        }
        public OptimizeOutput(
            IExpressionOutput <T> output, OptimizeModes mode, bool checks)
        {
            Debug.Assert(output != null);

            this.output = output;
            this.mode   = mode;

            this.interp = QuickInterpret <T> .Create(checks, null);
        }
Пример #3
0
        public void Parse(
            string expression, IExpressionOutput <T> exprOutput)
        {
            Debug.Assert(expression != null);
            Debug.Assert(exprOutput != null);

            this.expr = expression;
            //this.xlen = expression.Length;
            this.output    = exprOutput;
            this.exprDepth = 0;
            this.prePos    = 0;
            this.value     = default(T);

            int i = 0;

            Parse(ref i, false);
        }
Пример #4
0
        void ParseOptimized(string expression, IExpressionOutput <T> output)
        {
            if (this.parser == null)
            {
                this.parser = new Parser <T>(this);
            }

            if (this.optimizeMode == OptimizeModes.None)
            {
                this.parser.Parse(expression, output);
            }
            else
            {
                var optimizer = new OptimizeOutput <T>(
                    output, Optimization, OverflowCheck);

                this.parser.Parse(expression, optimizer);
            }
        }
Пример #5
0
        public void WriteTo(IExpressionOutput <T> output)
        {
            int i = 0, n = 0,
                f = 0, d = 0;

            while (true)
            {
                Code op = this.code[i++];

                if (CodeHelper.IsOp(op))
                {
                    output.PutOperator(op);
                }
                else if (op == Code.Number)
                {
                    output.PutConstant(this.numbers[n++]);
                }
                else if (op == Code.Argument)
                {
                    output.PutArgument(this.data[d++]);
                }
                else if (op == Code.Function)
                {
                    output.PutCall(
                        this.functions[f++], this.data[d++]);
                }
                else if (op == Code.Separator)
                {
                    output.PutSeparator();
                }
                else if (op == Code.BeginCall)
                {
                    output.PutBeginCall();
                }
                else
                {
                    output.PutExprEnd(); break;
                }
            }
        }