Ejemplo n.º 1
0
 public Boolean equals(Object o)
 {
     if (o is XPathNumericLiteral)
     {
         XPathNumericLiteral x = (XPathNumericLiteral)o;
         return(Double.IsNaN(d) ? Double.IsNaN(x.d) : d == x.d);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
 public override bool Equals(System.Object o)
 {
     if (o is XPathNumericLiteral)
     {
         XPathNumericLiteral x = (XPathNumericLiteral)o;
         return(System.Double.IsNaN(d)?System.Double.IsNaN(x.d):d == x.d);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 3
0
        public void print(Object o)
        {
            indent += 1;

            if (o is XPathStringLiteral)
            {
                XPathStringLiteral x = (XPathStringLiteral)o;
                printStr("strlit {" + x.s + "}");
            }
            else if (o is XPathNumericLiteral)
            {
                XPathNumericLiteral x = (XPathNumericLiteral)o;
                printStr("numlit {" + x.d + "}");
            }
            else if (o is XPathVariableReference)
            {
                XPathVariableReference x = (XPathVariableReference)o;
                printStr("var {" + x.id.ToString() + "}");
            }
            else if (o is XPathArithExpr)
            {
                XPathArithExpr x  = (XPathArithExpr)o;
                String         op = null;
                switch (x.op)
                {
                case XPathArithExpr.ADD: op = "add"; break;

                case XPathArithExpr.SUBTRACT: op = "subtr"; break;

                case XPathArithExpr.MULTIPLY: op = "mult"; break;

                case XPathArithExpr.DIVIDE: op = "div"; break;

                case XPathArithExpr.MODULO: op = "mod"; break;
                }
                printStr(op + " {{");
                print(x.a);
                printStr(" } {");
                print(x.b);
                printStr("}}");
            }
            else if (o is XPathBoolExpr)
            {
                XPathBoolExpr x  = (XPathBoolExpr)o;
                String        op = null;
                switch (x.op)
                {
                case XPathBoolExpr.AND: op = "and"; break;

                case XPathBoolExpr.OR: op = "or"; break;
                }
                printStr(op + " {{");
                print(x.a);
                printStr(" } {");
                print(x.b);
                printStr("}}");
            }
            else if (o is XPathCmpExpr)
            {
                XPathCmpExpr x  = (XPathCmpExpr)o;
                String       op = null;
                switch (x.op)
                {
                case XPathCmpExpr.LT: op = "lt"; break;

                case XPathCmpExpr.LTE: op = "lte"; break;

                case XPathCmpExpr.GT: op = "gt"; break;

                case XPathCmpExpr.GTE: op = "gte"; break;
                }
                printStr(op + " {{");
                print(x.a);
                printStr(" } {");
                print(x.b);
                printStr("}}");
            }
            else if (o is XPathEqExpr)
            {
                XPathEqExpr x  = (XPathEqExpr)o;
                String      op = x.equal ? "eq" : "neq";
                printStr(op + " {{");
                print(x.a);
                printStr(" } {");
                print(x.b);
                printStr("}}");
            }
            else if (o is XPathUnionExpr)
            {
                XPathUnionExpr x = (XPathUnionExpr)o;
                printStr("union {{");
                print(x.a);
                printStr(" } {");
                print(x.b);
                printStr("}}");
            }
            else if (o is XPathNumNegExpr)
            {
                XPathNumNegExpr x = (XPathNumNegExpr)o;
                printStr("neg {");
                print(x.a);
                printStr("}");
            }
            else if (o is XPathFuncExpr)
            {
                XPathFuncExpr x = (XPathFuncExpr)o;
                if (x.args.Length == 0)
                {
                    printStr("func {" + x.id.ToString() + ", args {none}}");
                }
                else
                {
                    printStr("func {" + x.id.ToString() + ", args {{");
                    for (int i = 0; i < x.args.Length; i++)
                    {
                        print(x.args[i]);
                        if (i < x.args.Length - 1)
                        {
                            printStr(" } {");
                        }
                    }
                    printStr("}}}");
                }
            }
            else if (o is XPathPathExpr)
            {
                XPathPathExpr x    = (XPathPathExpr)o;
                String        init = null;

                switch (x.init_context)
                {
                case XPathPathExpr.INIT_CONTEXT_ROOT: init = "root"; break;

                case XPathPathExpr.INIT_CONTEXT_RELATIVE: init = "relative"; break;

                case XPathPathExpr.INIT_CONTEXT_EXPR: init = "expr"; break;
                }

                printStr("path {init-context:" + init + ",");

                if (x.init_context == XPathPathExpr.INIT_CONTEXT_EXPR)
                {
                    printStr(" init-expr:{");
                    print(x.filtExpr);
                    printStr(" }");
                }

                if (x.steps.Length == 0)
                {
                    printStr(" steps {none}");
                    printStr("}");
                }
                else
                {
                    printStr(" steps {{");
                    for (int i = 0; i < x.steps.Length; i++)
                    {
                        print(x.steps[i]);
                        if (i < x.steps.Length - 1)
                        {
                            printStr(" } {");
                        }
                    }
                    printStr("}}}");
                }
            }
            else if (o is XPathFilterExpr)
            {
                XPathFilterExpr x = (XPathFilterExpr)o;

                printStr("filter-expr:{{");
                print(x.x);

                if (x.predicates.Length == 0)
                {
                    printStr(" } predicates {none}}");
                }
                else
                {
                    printStr(" } predicates {{");
                    for (int i = 0; i < x.predicates.Length; i++)
                    {
                        print(x.predicates[i]);
                        if (i < x.predicates.Length - 1)
                        {
                            printStr(" } {");
                        }
                    }
                    printStr(" }}}");
                }
            }
            else if (o is XPathStep)
            {
                XPathStep x    = (XPathStep)o;
                String    axis = null;
                String    test = null;

                axis = XPathStep.axisStr(x.axis);
                test = x.testStr();

                if (x.predicates.Length == 0)
                {
                    printStr("step {axis:" + axis + " test:" + test + " predicates {none}}");
                }
                else
                {
                    printStr("step {axis:" + axis + " test:" + test + " predicates {{");
                    for (int i = 0; i < x.predicates.Length; i++)
                    {
                        print(x.predicates[i]);
                        if (i < x.predicates.Length - 1)
                        {
                            printStr(" } {");
                        }
                    }
                    printStr("}}}");
                }
            }

            indent -= 1;
        }