コード例 #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);
        }
コード例 #2
0
        internal Object ReadEndDelimiter(params Object[] args)
        {
            LocTextReader t = (LocTextReader)args[0];
            //so we can complain
            EndDelimiter ed = new EndDelimiter();

            //Char c = (Char)args[1];//t.Read();
            ed.delim = (Char)args[1];    //t.Read();
            return(ed);
            //throw new Exception("Read error - read unmatched: " + c);
        }
コード例 #3
0
 internal Object ReadEndDelimiter(params Object[] args)
 {
     LocTextReader t = (LocTextReader)args[0];
     //so we can complain
     EndDelimiter ed = new EndDelimiter();
     //Char c = (Char)args[1];//t.Read();
     ed.delim = (Char)args[1];//t.Read();
     return ed;
     //throw new Exception("Read error - read unmatched: " + c);
 }