Exemplo n.º 1
0
        public static ExprNode MathGetExpr(IParseTree ctx, IDictionary <ITree, ExprNode> astExprNodeMap, ConfigurationInformation configurationInformation)
        {
            var count = 1;
            var @base = ASTExprHelper.ExprCollectSubNodes(ctx.GetChild(0), 0, astExprNodeMap)[0];

            while (true)
            {
                int token             = ASTUtil.GetAssertTerminatedTokenType(ctx.GetChild(count));
                var mathArithTypeEnum = TokenToMathEnum(token);

                var right = ASTExprHelper.ExprCollectSubNodes(ctx.GetChild(count + 1), 0, astExprNodeMap)[0];

                var math = new ExprMathNode(mathArithTypeEnum,
                                            configurationInformation.EngineDefaults.ExpressionConfig.IsIntegerDivision,
                                            configurationInformation.EngineDefaults.ExpressionConfig.IsDivisionByZeroReturnsNull);
                math.AddChildNode(@base);
                math.AddChildNode(right);
                @base = math;

                count += 2;
                if (count >= ctx.ChildCount)
                {
                    break;
                }
            }
            return(@base);
        }