Exemplo n.º 1
0
        private void checkForNegativeArc(option location, node fromLNode, node fromHostNode,
                                         ruleArc newLArc)
        {
            var currentLArcIndex = L.arcs.IndexOf(newLArc);

            /* so, currentLArcIndex now, points to a LArc that has yet to be recognized. What we do from
             * this point depends on whether that LArc points to an L node we have yet to recognize, an L
             * node we have recognized, or null. */
            var nextLNode = (ruleNode)newLArc.otherNode(fromLNode);
            /* first we must match the arc to a possible arc leaving the fromHostNode .*/
            node nextHostNode = (nextLNode == null) ? null : location.findLMappedNode(nextLNode);

            var neighborHostArcs = fromHostNode.arcs.FindAll(a =>
                                                             (a is arc && !location.arcs.Contains(a)) &&
                                                             arcMatches(newLArc, (arc)a, fromHostNode, nextHostNode, (newLArc.From == fromLNode))).Cast <arc>();

            if ((nextHostNode != null) || newLArc.nullMeansNull)
            {
                foreach (var HostArc in neighborHostArcs)
                {
                    var newLocation = location.copy();
                    newLocation.arcs[currentLArcIndex] = HostArc;
                    findNegativeStartElement(newLocation);
                    if ((bool)AllNegativeElementsFound)
                    {
                        return;                                 /* another sub-branch found a match to the negative elements.
                                                                 * There's no point in finding more than one, so this statement
                                                                 * aborts the search down this branch. */
                    }
                }
            }
            else
            {
                foreach (var HostArc in neighborHostArcs)
                {
                    nextHostNode = HostArc.otherNode(fromHostNode);
                    if (!location.nodes.Contains(nextHostNode))
                    {
                        var newLocation = location.copy();
                        newLocation.arcs[currentLArcIndex] = HostArc;
                        if (nextLNode == null)
                        {
                            findNegativeStartElement(newLocation);
                        }
                        else
                        {
                            checkForNegativeNode(newLocation, nextLNode, nextHostNode);
                        }
                    }
                    if ((bool)AllNegativeElementsFound)
                    {
                        return;                                 /* another sub-branch found a match to the negative elements.
                                                                 * There's no point in finding more than one, so this statement
                                                                 * aborts the search down this branch. */
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void checkArcAvoidNegatives(option location, node fromLNode, node fromHostNode,
                                            ruleArc newLArc)
        {
            var currentLArcIndex = L.arcs.IndexOf(newLArc);

            /* so, currentLArcIndex now, points to a LArc that has yet to be recognized. What we do from
             * this point depends on whether that LArc points to an L node we have yet to recognize, an L
             * node we have recognized, or null. */
            var nextLNode = (ruleNode)newLArc.otherNode(fromLNode);
            /* first we must match the arc to a possible arc leaving the fromHostNode .*/
            var nextHostNode = (nextLNode == null || nextLNode.NotExist) ? null
                               : location.findLMappedNode(nextLNode);

            var neighborHostArcs = fromHostNode.arcs.FindAll(a =>
                                                             (a is arc && !location.arcs.Contains(a)) &&
                                                             (arcMatches(newLArc, (arc)a, fromHostNode, nextHostNode, (newLArc.From == fromLNode)) ||
                                                              arcMatchRelaxed(newLArc, (arc)a, location, fromHostNode, nextHostNode, (newLArc.From == fromLNode)))).Cast <arc>();

            //relaxelt
            if ((nextHostNode != null) || newLArc.nullMeansNull)
            {
                foreach (var HostArc in neighborHostArcs)
                {
                    var newLocation = location.copy();
                    newLocation.arcs[currentLArcIndex] = HostArc;
                    FindPositiveStartElementAvoidNegatives(newLocation);
                }
            }
            else
            {
                foreach (var HostArc in neighborHostArcs)
                {
                    nextHostNode = HostArc.otherNode(fromHostNode);
                    if (!location.nodes.Contains(nextHostNode))
                    {
                        var newLocation = location.copy();
                        newLocation.arcs[currentLArcIndex] = HostArc;
                        if (nextLNode == null || nextLNode.NotExist)
                        {
                            FindPositiveStartElementAvoidNegatives(newLocation);
                        }
                        else
                        {
                            checkNodeAvoidNegatives(newLocation, nextLNode, nextHostNode);
                        }
                    }
                }
            }
        }