Пример #1
0
        private void LazyLoadPath(VirtualForestNodePath path)
        {
            var transitionState    = path.TransitionState;
            var completedParseNode = path.ForestNode;

            if (transitionState.NextTransition != null)
            {
                var virtualNode = new VirtualForestNode(Location, transitionState.NextTransition, completedParseNode);

                if (transitionState.Reduction.ParseNode == null)
                {
                    AddUniqueFamily(virtualNode);
                }
                else
                {
                    AddUniqueFamily(transitionState.Reduction.ParseNode, virtualNode);
                }
            }
            else if (transitionState.Reduction.ParseNode != null)
            {
                AddUniqueFamily(transitionState.Reduction.ParseNode, completedParseNode);
            }
            else
            {
                AddUniqueFamily(completedParseNode);
            }
        }
Пример #2
0
        public void AddUniquePath(VirtualForestNodePath path)
        {
            if (!IsUniquePath(path))
                return;
            if (IsUniqueChildSubTree(path))
                CloneUniqueChildSubTree(path.ForestNode as IInternalForestNode);

            _paths.Add(path);
        }
Пример #3
0
        private static bool IsUniqueChildSubTree(VirtualForestNodePath path)
        {
            var transitionState    = path.TransitionState;
            var completedParseNode = path.ForestNode;

            return(transitionState.Reduction.ParseNode != null &&
                   completedParseNode == transitionState.Reduction.ParseNode &&
                   (completedParseNode.NodeType == ForestNodeType.Intermediate ||
                    completedParseNode.NodeType == ForestNodeType.Symbol));
        }
Пример #4
0
 private bool IsUniquePath(VirtualForestNodePath path)
 {
     for (int p = 0; p < _paths.Count; p++)
     {
         var otherPath = _paths[p];
         if (path.Equals(otherPath))
         {
             return(false);
         }
     }
     return(true);
 }
Пример #5
0
        public void AddUniquePath(VirtualForestNodePath path)
        {
            if (!IsUniquePath(path))
            {
                return;
            }
            if (IsUniqueChildSubTree(path))
            {
                CloneUniqueChildSubTree(path.ForestNode as IInternalForestNode);
            }

            _paths.Add(path);
        }
Пример #6
0
        protected VirtualForestNode(
            int location,
            ITransitionState transitionState,
            IForestNode completedParseNode,
            IState targetState)
            : base(targetState.Origin, location)
        {
            _paths = new List<VirtualForestNodePath>();

            Symbol = targetState.Production.LeftHandSide;
            _hashCode = ComputeHashCode();
            var path = new VirtualForestNodePath(transitionState, completedParseNode);
            AddUniquePath(path);
        }
Пример #7
0
        protected VirtualForestNode(
            int location,
            ITransitionState transitionState,
            IForestNode completedParseNode,
            IState targetState)
            : base(targetState.Origin, location)
        {
            _paths = new List <VirtualForestNodePath>();

            Symbol    = targetState.DottedRule.Production.LeftHandSide;
            _hashCode = ComputeHashCode();
            var path = new VirtualForestNodePath(transitionState, completedParseNode);

            AddUniquePath(path);
        }
Пример #8
0
        private void LazyLoadPath(VirtualForestNodePath path)
        {
            var transitionState = path.TransitionState;
            var completedParseNode = path.ForestNode;
            if (transitionState.NextTransition != null)
            {
                var virtualNode = new VirtualForestNode(Location, transitionState.NextTransition, completedParseNode);

                if (transitionState.Reduction.ParseNode == null)
                    AddUniqueFamily(virtualNode);
                else
                    AddUniqueFamily(transitionState.Reduction.ParseNode, virtualNode);
            }
            else if (transitionState.Reduction.ParseNode != null)
            {
                AddUniqueFamily(transitionState.Reduction.ParseNode, completedParseNode);
            }
            else
            {
                AddUniqueFamily(completedParseNode);
            }
        }
Пример #9
0
 private bool IsUniquePath(VirtualForestNodePath path)
 {
     for (int p = 0; p < _paths.Count; p++)
     {
         var otherPath = _paths[p];
         if(path.Equals(otherPath))
             return false;
     }
     return true;
 }
Пример #10
0
        private static bool IsUniqueChildSubTree(VirtualForestNodePath path)
        {
            var transitionState = path.TransitionState;
            var completedParseNode = path.ForestNode;

            return transitionState.Reduction.ParseNode != null
            && completedParseNode == transitionState.Reduction.ParseNode
            && (completedParseNode.NodeType == ForestNodeType.Intermediate
                || completedParseNode.NodeType == ForestNodeType.Symbol);
        }