Example #1
0
        private void Expr(ExprNode node)
        {
            int tmp = index;

            Unary(new UnaryNode());
            if (TagIs(Tag.DL_SET))
            {
                index           = tmp;
                node.assignment = new AssignmentExprNode();
                AssignmentExpr(node.assignment);
            }
            else
            {
                index = tmp;
                var child = node.AddChild(new AndExprNode());
                AndExpr(child);
                while (TagIs(Tag.DL_OR))
                {
                    child    = node.AddChild(new AndExprNode());
                    child.Op = Tag.DL_OR;
                    Move();
                    AndExpr(child);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Return an expression tree with the structure of the target paths and leaves corresponding to the source paths.
        /// </summary>
        public ExprNode BuildExpression(ActionType action)
        {
            // Two algorithms:
            // - for all matches: add all target paths to the expression root and for each of them generate a continuation from the source path by attaching to the leaf
            // - generate separately a target tree in a separate method. for each leaf, generate a continuation path and attach it to the leaf

            // Methods:
            // - ExprNode = CreateCall(ColumnPath path). generate a sequential access expression from a path (optionally with 'this' formatted for the initial table in the leaf)
            //   - take into account Oledb by instantiating correct epxr node type
            //   - alternativey, add the path to a tree node
            // - Expr::AddToTuple(ColumnPath path). add a path to an existing tree. here we have to know
            //   - criterion of equality of path segment and tree node,
            //   - a method for creating a node from a path segment
            //   - the semantics of adding from the point of view of tree operation (expr node has to be parameterized accordingly)
            // - Mapping::BuildTupleTree() Expr::CreateTuple(Mapping) build a source/target tree from a mapping (or from a list of paths)
            //   - add all paths sequentially to the expression tree
            //   - returning leaves of an expression tree (in order to attach continuation paths)


            // Create root tuple expression corresponding to the table
            ExprNode tupleExpr = new ExprNode();

            tupleExpr.Operation = OperationType.TUPLE;
            tupleExpr.Action    = action;
            tupleExpr.Name      = ""; // This tuple is not a member in any other tuple

            tupleExpr.OutputVariable.SchemaName = TargetTab.Schema.Name;
            tupleExpr.OutputVariable.TypeName   = TargetTab.Name;
            tupleExpr.OutputVariable.TypeSchema = TargetTab.Schema;
            tupleExpr.OutputVariable.TypeTable  = TargetTab; // This tuple is a member in the table

            // For each match, add a tuple branch and then an access call
            foreach (PathMatch match in Matches)
            {
                // Add a branch into the tuple tree
                ExprNode leafNode = tupleExpr.AddToTuple(match.TargetPath, false);

                // Add an access expression to this branch
                ExprNode accessNode = ExprNode.CreateReader(match.SourcePath, true);
                leafNode.AddChild((ExprNode)accessNode.Root);
                // TODO: Old question: what is in the tuple leaves: VALUE, CALL, or whatever
            }

            return(tupleExpr);
        }