public bool getSemi()
        {
            semiExp.RemoveRange(0, semiExp.Count);  // empty container
            do
            {
                get();
                if (currTok == "")
                {
                    return(false);  // end of file
                }
                //if (returnNewLines || currTok != "\n")
                semiExp.Add(currTok);
            } while (!isTerminator(currTok) || count == 0);

            // if for then append next two semiExps, e.g., for(int i=0; i<se.count; ++i) {

            trim();

            if (semiExp.Contains("for"))
            {
                SemiExp se = clone();
                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);
        }
Beispiel #2
0
        public bool getSemi()
        {
            semiExp.RemoveRange(0, semiExp.Count);
            do
            {
                get();
                if (currTok == "")
                    return false;

                semiExp.Add(currTok);
            } while (!isTerminator(currTok) || count == 0);

            trim();

            if (semiExp.Contains("for"))
            {
                SemiExp se = clone();
                getSemi();
                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);
        }
Beispiel #3
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;
        }
Beispiel #4
0
 public void trim()
 {
     SemiExp temp = new SemiExp();
     foreach (string tok in semiExp)
     {
         if (isWhiteSpace(tok))
             continue;
         temp.Add(tok);
     }
     semiExp = temp.semiExp;
 }