Example #1
0
            public override void Visit(ISymbolForestNode symbolNode)
            {
                if (!this.visited.Add(symbolNode))
                {
                    return;
                }

                var childIndex = GetOrSetChildIndex(symbolNode);

                var path             = symbolNode.Children[childIndex];
                var internalTreeNode = new InternalTreeNodeImpl(
                    symbolNode.Origin,
                    symbolNode.Location,
                    symbolNode.Symbol as NonTerminal);

                var isRoot = this.nodeStack.Count == 0;

                if (!isRoot)
                {
                    this.nodeStack
                    .Peek()
                    .ReadWriteChildren
                    .Add(internalTreeNode);
                }

                this.nodeStack.Push(internalTreeNode);

                Visit(path);

                var top = this.nodeStack.Pop();

                if (isRoot)
                {
                    if (this.count > 0 && this._lock == null)
                    {
                        Root = null;
                    }
                    else
                    {
                        Root = top;
                    }

                    this.count++;
                    this.visited.Clear();
                }
            }
Example #2
0
            public override void Visit(ISymbolForestNode symbolNode)
            {
                if (!_visited.Add(symbolNode))
                    return;

                int childIndex = GetOrSetChildIndex(symbolNode);

                var path = symbolNode.Children[childIndex];
                var internalTreeNode = new InternalTreeNodeImpl(
                    symbolNode.Origin,
                    symbolNode.Location,
                    symbolNode.Symbol as INonTerminal);

                var isRoot = _nodeStack.Count == 0;
                if (!isRoot)
                {
                    _nodeStack
                        .Peek()
                        .ReadWriteChildren
                        .Add(internalTreeNode);
                }

                _nodeStack.Push(internalTreeNode);

                Visit(path);

                var top = _nodeStack.Pop();

                if (isRoot)
                {
                    if (_count > 0 && _lock == null)
                        Root = null;
                    else
                        Root = top;
                    _count++;
                    _visited.Clear();
                }
            }