Ejemplo n.º 1
0
        private NPathExpression ParseOperator(IValue leftOperand)
        {
            NPathExpression current = null;

            if (tokenizer.GetCurrentToken().IsType("boolop"))
            {
                current = ParseBooleanOperator(leftOperand);
            }

            if (tokenizer.GetCurrentToken().IsType("compare"))
            {
                current = ParseCompareOperator(leftOperand);
            }

            if (tokenizer.GetCurrentToken().IsType("math"))
            {
                current = ParseMathOperator(leftOperand);
            }


            current = SwapNodes(current);


            return(current);
        }
Ejemplo n.º 2
0
        private NPathExpression SwapNodes(NPathExpression current)
        {
            if (current.RightOperand is NPathExpression)
            {
                NPathExpression next  = current.RightOperand as NPathExpression;
                int             prio1 = current.GetOperatorPriority();
                int             prio2 = next.GetOperatorPriority();
                if (prio2 < prio1)
                {
                    NPathExpression tmp = current;
                    current = next;
                    next    = tmp;

                    IValue nextLeft    = next.LeftOperand;
                    IValue currentLeft = next.LeftOperand;

                    IValue nextRight    = next.RightOperand;
                    IValue currentRight = next.RightOperand;


                    //	(c = (b and (d = (f and (4 div (5 add (2 = (7 or (


                    //"c = "   "b and"    "d =" // do not localize
                    //"c = b" " and "  "d =" // do not localize

                    next.RightOperand = current.LeftOperand;
                    next = SwapNodes(next);
                    current.LeftOperand = next;
                }
            }
            return(current);
        }
Ejemplo n.º 3
0
        protected virtual void EmitSelect(NPathSelectQuery query)
        {
            NPathSelectClause select = query.Select;

            Write("select ");             // do not localize

            if (query.Select.HasTop)
            {
                Write("top {0}", query.Select.Top);                 // do not localize
                if (query.Select.Percent)
                {
                    Write("% ");
                }
            }
            int i = 0;

            foreach (NPathSelectField field in select.SelectFields)
            {
                if (field.Expression is NPathIdentifier)
                {
                    NPathIdentifier path = field.Expression as NPathIdentifier;
                    Write(path.Path);
                }
                if (field.Expression is NPathFunction)
                {
                    NPathFunction function = field.Expression as NPathFunction;
                    EmitFunction(function);
                }
                if (field.Expression is NPathExpression)
                {
                    NPathExpression expression = field.Expression as NPathExpression;
                    EmitExpression(expression);
                }

                if (field.Alias != null && field.Alias != "")
                {
                    WriteLine(" as [{0}]", field.Alias);                     // do not localize
                }

                if (i < select.SelectFields.Count - 1)
                {
                    Write(",");
                }
                i++;
            }
            WriteLine();
        }