Exemple #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);
            }
        }
        public void AddUniquePath(VirtualForestNodePath path)
        {
            if (!IsUniquePath(path))
                return;
            if (IsUniqueChildSubTree(path))
                CloneUniqueChildSubTree(path.ForestNode as IInternalForestNode);

            _paths.Add(path);
        }
        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));
        }
 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);
 }
        public void AddUniquePath(VirtualForestNodePath path)
        {
            if (!IsUniquePath(path))
            {
                return;
            }
            if (IsUniqueChildSubTree(path))
            {
                CloneUniqueChildSubTree(path.ForestNode as IInternalForestNode);
            }

            _paths.Add(path);
        }
        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);
        }
        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);
        }
        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);
            }
        }
 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;
 }
Exemple #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);
        }