internal FdoSpatialCondition(ParseTreeNode node)
        {
            this.Identifier = new FdoIdentifier(node.ChildNodes[0]);
            var opName = node.ChildNodes[1].ChildNodes[0].Token.ValueString;

            switch (opName.ToUpper())
            {
            case "CONTAINS":
                this.Operator = SpatialOperations.Contains;
                break;

            case "CROSSES":
                this.Operator = SpatialOperations.Crosses;
                break;

            case "DISJOINT":
                this.Operator = SpatialOperations.Disjoint;
                break;

            case "EQUALS":
                this.Operator = SpatialOperations.Equals;
                break;

            case "INTERSECTS":
                this.Operator = SpatialOperations.Intersects;
                break;

            case "OVERLAPS":
                this.Operator = SpatialOperations.Overlaps;
                break;

            case "TOUCHES":
                this.Operator = SpatialOperations.Touches;
                break;

            case "WITHIN":
                this.Operator = SpatialOperations.Within;
                break;

            case "COVEREDBY":
                this.Operator = SpatialOperations.CoveredBy;
                break;

            case "INSIDE":
                this.Operator = SpatialOperations.Inside;
                break;

            default:
                throw new FdoParseException(string.Format(Strings.UnknownOperator, opName));
            }
            this.Expression = FdoExpression.ParseNode(node.ChildNodes[2]);
        }
Пример #2
0
 private void ProcessNodeList(ParseTreeNodeList list)
 {
     foreach (ParseTreeNode child in list)
     {
         if (child.Term.Name == FdoTerminalNames.ExpressionCollection)
         {
             ProcessNodeList(child.ChildNodes);
         }
         else
         {
             this.Arguments.Add(FdoExpression.ParseNode(child));
         }
     }
 }
Пример #3
0
        internal FdoDistanceCondition(ParseTreeNode node)
        {
            this.Identifier = new FdoIdentifier(node.ChildNodes[0]);
            var opName = node.ChildNodes[1].ChildNodes[0].Token.ValueString;

            switch (opName.ToUpper())
            {
            case "WITHINDISTANCE":
                this.Operator = DistanceOperations.WithinDistance;
                break;

            case "BEYOND":
                this.Operator = DistanceOperations.Beyond;
                break;

            default:
                throw new FdoParseException(string.Format(Strings.UnknownOperator, opName));
            }
            this.Expression = FdoExpression.ParseNode(node.ChildNodes[2]);
            this.Distance   = FdoDataValue.ParseDataNode(node.ChildNodes[3].ChildNodes[0]);
        }
Пример #4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="node"></param>
        internal FdoComparisonCondition(ParseTreeNode node)
        {
            this.Left = FdoExpression.ParseNode(node.ChildNodes[0]);
            var opName = node.ChildNodes[1].ChildNodes[0].Token.ValueString;

            switch (opName.ToUpper())
            {
            case "=":
                this.Operator = ComparisonOperations.EqualsTo;
                break;

            case "<>":
                this.Operator = ComparisonOperations.NotEqualsTo;
                break;

            case ">":
                this.Operator = ComparisonOperations.GreaterThan;
                break;

            case ">=":
                this.Operator = ComparisonOperations.GreaterThanOrEqualTo;
                break;

            case "<":
                this.Operator = ComparisonOperations.LessThan;
                break;

            case "<=":
                this.Operator = ComparisonOperations.LessThanOrEqualTo;
                break;

            case "LIKE":
                this.Operator = ComparisonOperations.Like;
                break;

            default:
                throw new FdoParseException("Unknown operator: " + opName);
            }
            this.Right = FdoExpression.ParseNode(node.ChildNodes[2]);
        }
 internal FdoUnaryExpression(ParseTreeNode node)
 {
     this.Expression = FdoExpression.ParseNode(node.ChildNodes[0]);
 }
Пример #6
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="node"></param>
        internal FdoBinaryExpression(ParseTreeNode node)
        {
            this.Left = FdoExpression.ParseNode(node.ChildNodes[0]);
            //HACK: Workaround bug in parser or grammar specification where (a - b) produces a: Expression, b: Expression
            if (node.ChildNodes.Count == 2)
            {
                var expr = FdoExpression.ParseNode(node.ChildNodes[1]);
                this.Operator = BinaryOperator.Subtract;
                this.Right    = expr;

                /*
                 * if (expr is FdoUnaryExpression)
                 * {
                 *  this.Operator = BinaryOperator.Subtract;
                 *  this.Right = ((FdoUnaryExpression)expr).Expression;
                 * }
                 * else if (expr is FdoDataValue)
                 * {
                 *  var dt = ((FdoDataValue)expr).DataType;
                 *  switch (dt)
                 *  {
                 *      case DataType.Double:
                 *          {
                 *              FdoDoubleValue dbl = (FdoDoubleValue)expr;
                 *              if (dbl.Value < 0.0)
                 *              {
                 *                  this.Operator = BinaryOperator.Subtract;
                 *                  this.Right = dbl.Negate();
                 *              }
                 *              else
                 *              {
                 *                  this.Operator = BinaryOperator.Add;
                 *                  this.Right = expr;
                 *              }
                 *          }
                 *          break;
                 *      case DataType.Int32:
                 *          {
                 *              FdoInt32Value iv = (FdoInt32Value)expr;
                 *              if (iv.Value < 0)
                 *              {
                 *                  this.Operator = BinaryOperator.Subtract;
                 *                  this.Right = iv.Negate();
                 *              }
                 *              else
                 *              {
                 *                  this.Operator = BinaryOperator.Add;
                 *                  this.Right = expr;
                 *              }
                 *          }
                 *          break;
                 *      default:
                 *          throw new FdoParseException("Could not parse as Binary Expression");
                 *  }
                 * }
                 * else
                 * {
                 *  throw new FdoParseException("Could not parse as Binary Expression");
                 * }
                 */
            }
            else
            {
                var opStr = node.ChildNodes[1].Token.ValueString;
                switch (opStr)
                {
                case "+":
                    this.Operator = BinaryOperator.Add;
                    break;

                case "-":
                    this.Operator = BinaryOperator.Subtract;
                    break;

                case "/":
                    this.Operator = BinaryOperator.Divide;
                    break;

                case "*":
                    this.Operator = BinaryOperator.Multiply;
                    break;

                default:
                    throw new FdoParseException(string.Format(Strings.UnknownOperator, opStr));
                }
                this.Right = FdoExpression.ParseNode(node.ChildNodes[2]);
            }
        }