Beispiel #1
0
 public override Literal MakeVarsAnnon(Unifier un)
 {
     if (annotations != null)
     {
         IListTerm lt = annotations;
         while (!(lt.Count == 0))
         {
             ITerm ta = lt.GetTerm();
             if (ta.IsVar())
             {
                 lt.SetTerm(VarToReplace(ta, un));
             }
             else if (ta.GetType() == typeof(Structure))
             {
                 ((Structure)ta).MakeVarsAnnon(un);
             }
             if (lt.IsTail() && lt.GetNext().IsVar())
             {
                 lt.SetNext(VarToReplace(lt.GetNext(), un));
                 break;
             }
             lt = lt.GetNext();
         }
     }
     return(base.MakeVarsAnnon(un));
 }
Beispiel #2
0
            //public bool HasNext()
            //{
            //    if (c == null) // the first call of hasNext should find the first response
            //        Find();
            //    return c != null;
            //}

            //public Unifier Next()
            //{
            //    if (c == null) Find();
            //    Unifier b = c;
            //    Find(); // find next response
            //    return b;
            //}

            void Find()
            {
                while (listOutter != null && listOutter.Count != 0)
                {
                    while (list.Count != 0)
                    {
                        IListTerm candidate = AsSyntax.AsSyntax.CreateList(list);
                        list.Remove(list.ElementAt(list.Count - 1));
                        c = un.Clone();
                        if (c.UnifiesNoUndo(sublist, candidate))
                        {
                            return; // found another sublist, c is the current response
                        }
                    }
                    listOutter = listOutter.GetNext();
                    if (listOutter == null || listOutter.IsVar()) // the case of lists with tail
                    {
                        break;
                    }
                    list = listOutter.GetAsList();
                }
                if (!triedEmpty)
                {
                    triedEmpty = true;
                    c          = un.Clone();
                    if (c.UnifiesNoUndo(sublist, AsSyntax.AsSyntax.CreateList()))
                    {
                        return; // found another sublist, c is the current response
                    }
                }
                c = null; // no more sublists found
            }
Beispiel #3
0
 public void MyMoveNext()
 {
     current = nextLT;
     nextLT  = nextLT.GetNext();
 }