Example #1
0
        internal Cons readDelimitedList(LocTextReader t, Int32 delim)
        {
            Cons ret  = null;
            Cons tail = null;

            Int32 ch = t.Peek();

            while (Char.IsWhiteSpace((Char)ch))
            {
                t.Read();
                ch = t.Peek();
            }
            while (ch != delim)
            {
                Object o = doRead(t, delim == ')' && ret == null);
                if (eof(o))
                {
                    throw new Exception("Read error - eof found before matching: "
                                        + (Char)delim + "\n File: " + t.file + ", line: " + t.line);
                }
                EndDelimiter ed = o as EndDelimiter;
                if (ed != null)
                {
                    if (ed.delim == delim)
                    {
                        return(ret);
                    }
                    else
                    {
                        throw   new Exception("Read error - read unmatched: " + ed.delim
                                              + "\n File: " + t.file + ", line: " + t.line);
                    }
                }
                Cons link = new Cons(o, null);
                if (delim == ')' && ret == null && o is CompositeSymbol)
                {
                    ret  = ((CompositeSymbol)o).symbolAsList;
                    tail = ret.rest;
                }
                else if (ret == null)
                {
                    ret = tail = link;
                }
                else
                {
                    tail.rest = link;
                    tail      = link;
                }
                ch = t.Peek();
                while (Char.IsWhiteSpace((Char)ch))
                {
                    t.Read();
                    ch = t.Peek();
                }
            }

            //eat delim
            t.Read();
            return(ret);
        }
Example #2
0
        internal void eatMultiComment(LocTextReader t)
        {
            Int32 ch = t.Peek();

            while (ch != -1 && ch != '#')
            {
                t.Read();
                ch = t.Peek();
            }
            if (ch == '#')
            {
                t.Read();
            }
        }
Example #3
0
        internal void eatComment(LocTextReader t)
        {
            Int32 ch = t.Peek();

            while (ch != -1 && ch != '\n' && ch != '\r')
            {
                t.Read();
                ch = t.Peek();
            }
            if (ch != -1 && ch != '\n' && ch != '\r')
            {
                t.Read();
            }
        }
Example #4
0
        internal Object readSymbolOrNumber(LocTextReader t, Int32 ch, Boolean firstInForm)
        {
            StringBuilder b = new StringBuilder();

            b.Append((Char)ch);
            Boolean complete = false;

            while (!complete)
            {
                ch = t.Peek();
                if (ch == -1)
                {
                    complete = true;
                }
                else if (Char.IsWhiteSpace((Char)ch))
                {
                    complete = true;
                }
                else
                {
                    ReaderMacro rm = (ReaderMacro)macroTable[(Char)ch];
                    if (rm != null && rm.isTerminating)
                    {
                        complete = true;
                    }
                    else
                    {
                        t.Read();
                        b.Append((Char)ch);
                    }
                }
            }
            return(parseSymbolOrNumber(b.ToString(), firstInForm));
        }
Example #5
0
        internal void eatComment(LocTextReader t)
        {
            Int32 ch = t.Peek();

            while (ch != -1 && ch != '\n' && ch != '\r')
            {
                t.Read();
                ch = t.Peek();
            }
            // MEH: Why? Should never be true, or while would loop.
            //if(ch != -1 && ch != '\n' && ch != '\r')
            //	t.Read();
            // MEH: Guessing this was the intention:
            while (ch == '\n' || ch == '\r')
            {
                t.Read();
                ch = t.Peek();
            }
        }
Example #6
0
        internal Object ReadUnquote(params Object[] args)
        {
            LocTextReader t    = (LocTextReader)args[0];
            Int32         line = t.line;
            Int32         ch   = t.Peek();
            Object        ret  = null;

            if (ch == '@')
            {
                t.Read();
                ret = Cons.MakeList(interpreter.UNQUOTE_SPLICING, doRead(t, false));
            }
            else
            {
                ret = Cons.MakeList(interpreter.UNQUOTE, doRead(t, false));
            }
            //record the location
            locTable[ret] = new Loc(t.file, line);
            return(ret);
        }
Example #7
0
 internal Object readSymbolOrNumber(LocTextReader t,Int32 ch,Boolean firstInForm)
 {
     StringBuilder b = new StringBuilder();
     b.Append((Char)ch);
     Boolean complete = false;
     while(!complete)
     {
     ch = t.Peek();
     if(ch == -1)
         complete = true;
     else if(Char.IsWhiteSpace((Char)ch))
         complete = true;
     else
         {
         ReaderMacro rm = (ReaderMacro)macroTable[(Char)ch];
         if(rm != null && rm.isTerminating)
             complete = true;
         else
             {
             t.Read();
             b.Append((Char)ch);
             }
         }
     }
     return parseSymbolOrNumber(b.ToString(),firstInForm);
 }
Example #8
0
        internal Cons readDelimitedList(LocTextReader t,Int32 delim)
        {
            Cons ret = null;
            Cons tail = null;

            Int32 ch = t.Peek();
            while(Char.IsWhiteSpace((Char)ch))
            {
            t.Read();
            ch = t.Peek();
            }
            while(ch != delim)
            {
            Object o = doRead(t,delim == ')' && ret == null);
            if(eof(o))
                {
                throw new Exception("Read error - eof found before matching: "
                                          + (Char)delim + "\n File: " + t.file + ", line: " + t.line);
                }
            EndDelimiter ed = o as EndDelimiter;
            if(ed != null)
                {
                if(ed.delim == delim)
                    {
                    return ret;
                    }
                else
                    throw	new Exception("Read error - read unmatched: " + ed.delim
                                              + "\n File: " + t.file + ", line: " + t.line);
                }
            Cons link = new Cons(o,null);
            if(delim == ')' && ret == null && o is CompositeSymbol)
                {
                ret = ((CompositeSymbol)o).symbolAsList;
                tail = ret.rest;
                }
            else if(ret == null)
                {
                ret = tail = link;
                }
            else
                {
                tail.rest = link;
                tail = link;
                }
            ch = t.Peek();
            while(Char.IsWhiteSpace((Char)ch))
                {
                t.Read();
                ch = t.Peek();
                }
            }

            //eat delim
            t.Read();
            return ret;
        }
Example #9
0
 internal void eatMultiComment(LocTextReader t)
 {
     Int32 ch = t.Peek();
     while(ch != -1 && ch != '#')
     {
     t.Read();
     ch = t.Peek();
     }
     if(ch == '#')
     t.Read();
 }
Example #10
0
 internal void eatComment(LocTextReader t)
 {
     Int32 ch = t.Peek();
     while(ch != -1 && ch != '\n' && ch != '\r')
     {
     t.Read();
     ch = t.Peek();
     }
     if(ch != -1 && ch != '\n' && ch != '\r')
     t.Read();
 }
Example #11
0
	internal void eatComment(LocTextReader t)
		{
		Int32 ch = t.Peek();
		while(ch != -1 && ch != '\n' && ch != '\r')
			{
			t.Read();
			ch = t.Peek();
			}
		// MEH: Why? Should never be true, or while would loop.
		//if(ch != -1 && ch != '\n' && ch != '\r')
		//	t.Read();
		// MEH: Guessing this was the intention:
		while(ch == '\n' || ch == '\r')
			{
			t.Read();
			ch = t.Peek();
			}
		}