Beispiel #1
0
 public void Visit(AndForestNode andNode)
 {
     foreach (var child in andNode.Children)
     {
         child.Accept(this);
     }
 }
Beispiel #2
0
        private void LazyLoadChildren(AndForestNode andNode)
        {
            foreach (var child in andNode.Children)
            {
                switch (child)
                {
                // skip intermediate nodes by enumerating children only
                case IIntermediateForestNode intermediateNode:
                    var currentAndNode = this.disambiguationAlgorithm.GetCurrentAndNode(intermediateNode);
                    LazyLoadChildren(currentAndNode);
                    break;

                // create a internal tree node for symbol forest nodes
                case ISymbolForestNode symbolNode:
                    this.children.Add(new InternalTreeNode(symbolNode, this.disambiguationAlgorithm));
                    break;

                // create a tree token node for token forest nodes
                case ITokenForestNode tokenNode:
                    this.children.Add(new TokenTreeNode(tokenNode));
                    break;

                default:
                    throw new Exception("Unrecognized NodeType");
                }
            }
        }
Beispiel #3
0
        private bool AreAndNodesEqual(AndForestNode firstAndNode, AndForestNode secondAndNode)
        {
            if (firstAndNode.Children.Count != secondAndNode.Children.Count)
            {
                return(false);
            }

            for (var i = 0; i < firstAndNode.Children.Count; i++)
            {
                if (!Equals(
                        firstAndNode.Children[i],
                        secondAndNode.Children[i]))
                {
                    return(false);
                }
            }

            return(true);
        }