Ejemplo n.º 1
0
        public static void ExprCollectAddSubNodes(
            ExprNode parentNode,
            ITree node,
            IDictionary<ITree, ExprNode> astExprNodeMap)
        {
            if (parentNode == null)
            {
                throw ASTWalkException.From("Invalid null expression node for '" + ASTUtil.PrintNode(node) + "'");
            }

            if (node == null)
            {
                return;
            }

            ExprAction action = (exprNode, astExprNodeMapX, nodeX) => {
                astExprNodeMapX.Remove(nodeX);
                parentNode.AddChildNode(exprNode);
            };
            for (int i = 0; i < node.ChildCount; i++)
            {
                ITree childNode = node.GetChild(i);
                RecursiveFindRemoveChildExprNode(childNode, astExprNodeMap, action);
            }
        }
Ejemplo n.º 2
0
        public static void RegExCollectAddSubNodes(
            RowRecogExprNode regexNode,
            ITree node,
            IDictionary<ITree, RowRecogExprNode> astRegExNodeMap)
        {
            if (regexNode == null)
            {
                throw ASTWalkException.From("Invalid null expression node for '" + ASTUtil.PrintNode(node) + "'");
            }

            RegExAction action = (exprNode, astExprNodeMapX, nodeX) => {
                astExprNodeMapX.Remove(nodeX);
                regexNode.AddChildNode(exprNode);
            };
            for (int i = 0; i < node.ChildCount; i++)
            {
                ITree childNode = node.GetChild(i);
                RegExApplyActionRecursive(childNode, astRegExNodeMap, action);
            }
        }
Ejemplo n.º 3
0
        public static void PatternCollectAddSubnodesAddParentNode(
            EvalForgeNode evalNode,
            ITree node,
            IDictionary<ITree, EvalForgeNode> astPatternNodeMap)
        {
            if (evalNode == null)
            {
                throw ASTWalkException.From("Invalid null expression node for '" + ASTUtil.PrintNode(node) + "'");
            }

            for (int i = 0; i < node.ChildCount; i++)
            {
                var childNode = node.GetChild(i);
                EvalForgeNode childEvalNode = PatternGetRemoveTopNode(childNode, astPatternNodeMap);
                if (childEvalNode != null)
                {
                    evalNode.AddChildNode(childEvalNode);
                }
            }

            astPatternNodeMap.Put(node, evalNode);
        }