예제 #1
0
 public bool getSemi()
 {
     semiExp.RemoveRange(0, semiExp.Count);  // empty container
     do
     {
         get();
         if (currTok == "")
         {
             break;
         }                               // end of linea
         // check if comment
         if (!discardComments && isComment(currTok))
         {
             semiExp.Add(currTok);
         }
         else if (discardComments && isComment(currTok))
         {
             return(true);
         }
         else if ((currTok == "\r\n") && semiExp.Count > 0)
         {
             if (semiExp[0].StartsWith("#"))
             {
                 semiExp.Add(currTok); break;
             }
         }
         else if (returnNewLines || currTok != "\n")
         {
             semiExp.Add(currTok);
         }
         else
         {
             break;
         }
     } while (!isTerminator(currTok) || count == 0);
     trim();
     if (semiExp.Contains("for"))
     {
         SemiExp se = clone();       // make a copy of the semiExp
         getSemi();                  // note recursive call
         se.Add(semiExp.ToArray());
         getSemi();
         se.Add(semiExp.ToArray());
         semiExp.Clear();
         for (int i = 0; i < se.count; ++i)
         {
             semiExp.Add(se[i]);
         }
     }
     return(semiExp.Count > 0);
 }
예제 #2
0
        //
        //----< make a copy of semiEpression >-------------------------------

        public SemiExp clone()
        {
            SemiExp copy = new SemiExp();

            for (int i = 0; i < count; ++i)
            {
                copy.Add(this[i]);
            }
            return(copy);
        }
예제 #3
0
        //---------< get a set of a semi >------------------------------------
        public bool GetSemi()
        {
            semiExp.RemoveRange(0, semiExp.Count);  // empty container

            do
            {
                strb = toker.getTok();
                if (strb != null)
                {
                    semi = strb.ToString();
                }
                if (isComment(semi))    //throw the comment
                {
                    continue;
                }
                if (strb == null)    //end of file
                {
                    return(false);
                }
                if (returnNewLines || !semi.Equals("\n"))
                {
                    semiExp.Add(semi);
                }
            } while (!isTerminator(semi) || count == 0);

            trim();

            if (semiExp.Contains("for"))
            {
                SemiExp se = clone();
                GetSemi();              //recursively
                se.Add(semiExp.ToArray());
                GetSemi();
                se.Add(semiExp.ToArray());
                semiExp.Clear();
                for (int i = 0; i < se.count; i++)
                {
                    semiExp.Add(se[i]);
                }
            }
            return(semiExp.Count > 0);
        }
예제 #4
0
        public void trim()
        {
            SemiExp temp = new SemiExp();

            foreach (string tok in semiExp)
            {
                if (isWhiteSpace(tok))
                {
                    continue;
                }
                temp.Add(tok);
            }
            semiExp = temp.semiExp;
        }