Exemplo n.º 1
0
        private void LazyLoadChildren(IAndForestNode andNode)
        {
            for (int c = 0; c < andNode.Children.Count; c++)
            {
                var child = andNode.Children[c];
                switch (child.NodeType)
                {
                // skip intermediate nodes by enumerating children only
                case ForestNodeType.Intermediate:
                    var intermediateNode = child as IIntermediateForestNode;
                    var currentAndNode   = _disambiguationAlgorithm.GetCurrentAndNode(intermediateNode);
                    LazyLoadChildren(currentAndNode);
                    break;

                // create a internal tree node for symbol forest nodes
                case ForestNodeType.Symbol:
                    var symbolNode = child as ISymbolForestNode;
                    _children.Add(new InternalTreeNode(symbolNode, _disambiguationAlgorithm));
                    break;

                // create a tree token node for token forest nodes
                case ForestNodeType.Token:
                    _children.Add(new TokenTreeNode(child as ITokenForestNode));
                    break;

                default:
                    throw new Exception("Unrecognized NodeType");
                }
            }
        }
Exemplo n.º 2
0
 public override void Visit(IAndForestNode andNode)
 {
     foreach (var child in andNode.Children)
     {
         child.Accept(this);
     }
 }
Exemplo n.º 3
0
 public virtual void Visit(IAndForestNode andNode)
 {
     for (var c = 0; c < andNode.Children.Count; c++)
     {
         var child = andNode.Children[c];
         child.Accept(this);
     }
 }
Exemplo n.º 4
0
 public virtual void Visit(IAndForestNode andNode)
 {
     for (var c = 0; c < andNode.Children.Count; c++)
     {
         var child = andNode.Children[c];
         child.Accept(this);
     }
 }
 public void Visit(IAndForestNode andNode)
 {
     for (var i = 0; i < andNode.Children.Count; i++)
     {
         var child = andNode.Children[i];
         child.Accept(this);
     }
 }
Exemplo n.º 6
0
        private static bool IsMatchedSubTree(IForestNode firstChild, IForestNode secondChild, IAndForestNode andNode)
        {
            var firstCompareNode = andNode.Children[0];

            // if first child matches the compare node, continue
            // otherwise return false
            if (!firstChild.Equals(firstCompareNode))
                return false;

            if (secondChild == null)
                return true;

            var secondCompareNode = andNode.Children[1];

            // return true if the second child matches
            // otherwise return false
            return secondChild.Equals(secondCompareNode);
        }
Exemplo n.º 7
0
        bool AreAndNodesEqual(IAndForestNode firstAndNode, IAndForestNode secondAndNode)
        {
            if (firstAndNode.Children.Count != secondAndNode.Children.Count)
            {
                return(false);
            }

            for (int i = 0; i < firstAndNode.Children.Count; i++)
            {
                if (!Equals(
                        firstAndNode.Children[i],
                        secondAndNode.Children[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 8
0
 public override void Visit(IAndForestNode andNode)
 {
     foreach (var child in andNode.Children)
         child.Accept(this);
 }
Exemplo n.º 9
0
        private static bool IsMatchedSubTree(IForestNode firstChild, IForestNode secondChild, IAndForestNode andNode)
        {
            var firstCompareNode = andNode.Children[0];

            // if first child matches the compare node, continue
            // otherwise return false
            if (!firstChild.Equals(firstCompareNode))
            {
                return(false);
            }

            if (secondChild == null)
            {
                return(true);
            }

            var secondCompareNode = andNode.Children[1];

            // return true if the second child matches
            // otherwise return false
            return(secondChild.Equals(secondCompareNode));
        }
Exemplo n.º 10
0
        private void LazyLoadChildren(IAndForestNode andNode)
        {
            for (int c = 0; c < andNode.Children.Count; c++)
            {
                var child = andNode.Children[c];
                switch (child.NodeType)
                {
                    // skip intermediate nodes by enumerating children only
                    case ForestNodeType.Intermediate:
                        var intermediateNode = child as IIntermediateForestNode;
                        var currentAndNode = _disambiguationAlgorithm.GetCurrentAndNode(intermediateNode);
                        LazyLoadChildren(currentAndNode);
                        break;

                    // create a internal tree node for symbol forest nodes
                    case ForestNodeType.Symbol:
                        var symbolNode = child as ISymbolForestNode;
                        _children.Add(new InternalTreeNode(symbolNode, _disambiguationAlgorithm));
                        break;

                    // create a tree token node for token forest nodes
                    case ForestNodeType.Token:
                        _children.Add(new TokenTreeNode(child as ITokenForestNode));
                        break;

                    default:
                        throw new Exception("Unrecognized NodeType");
                }
            }
        }