Exemplo n.º 1
0
 public static string Top(Deck <Token> strVec, load_data.UserType ut, Reserver reserver)
 {
     if (strVec.empty() || strVec.GetFirst().Value.isComment)
     {
         if (false == ChkComment(strVec, ut, reserver, 1))
         {
             return("");
         }
     }
     if (strVec.empty())
     {
         return("");
     }
     return(strVec.GetFirst().Value.str);
 }
Exemplo n.º 2
0
// lookup just one!
        public static Pair <bool, Token> LookUp(Deck <Token> strVec, load_data.UserType ut, Reserver reserver)
        {
            if (!(strVec.size() >= 2 && false == strVec.GetFirst().Value.isComment&& false == strVec.get(1).isComment))
            {
                if (false == ChkComment(strVec, ut, reserver, 2))
                {
                    return(new Pair <bool, Token>(false, null));
                }
            }

            if (strVec.size() >= 2)
            {
                return(new Pair <bool, Token>(true, strVec.get(1)));
            }
            return(new Pair <bool, Token>(false, null));
        }
Exemplo n.º 3
0
        public static bool Pop(Deck <Token> strVec, ref String str, load_data.UserType ut, Reserver reserver)
        {
            if (strVec.empty() || strVec.GetFirst().Value.isComment)
            {
                if (false == ChkComment(strVec, ut, reserver, 1))
                {
                    return(false);
                }
            }

            if (strVec.empty())
            {
                return(false);
            }

            if (str != null)
            {
                str = strVec.GetFirst().Value.str;
            }
            strVec.pop_front();

            return(true);
        }
Exemplo n.º 4
0
        public static bool ChkComment(Deck <Token> strVec, load_data.UserType ut, Reserver reserver, int offset)
        {
            if (strVec.size() < offset)
            {
                reserver.Functor(strVec);
                while (strVec.size() < offset)                 //
                {
                    reserver.Functor(strVec);
                    if (
                        strVec.size() < offset &&
                        reserver.end()
                        )
                    {
                        return(false);
                    }
                }
            }

            LinkedListNode <Token> x = strVec.GetFirst();
            int count = 0;

            do
            {
                if (x.Value.isComment)
                {
                    ut.PushComment(x.Value.str);
                    x = strVec.remove(x);
                }
                else if (count == offset - 1)
                {
                    return(true);
                }
                else
                {
                    count++;
                    x = x.Next;
                }

                if (x == null)                   // chk
                {
                    reserver.Functor(strVec);
                    x = strVec.GetFirst();
                    for (int k = 0; k < count; ++k)
                    {
                        x = x.Next;
                    }
                    while (strVec.size() < offset)                     //
                    {
                        reserver.Functor(strVec);

                        if (
                            strVec.size() < offset &&
                            reserver.end()
                            )
                        {
                            return(false);
                        }
                    }
                    // chk here?
                    x = strVec.GetFirst();
                    for (int k = 0; k < count; ++k)
                    {
                        x = x.Next;
                    }
                }
            } while (true);
        }