예제 #1
0
        public override ReaderMacroStep NextStep()
        {
            Cons   head = null;
            object tail = null;

            Readtable currentReadtable = CL.Readtable;

            while (true)
            {
                int  xx;
                char x;
                // Discard whitespace
                do
                {
                    xx = this.context.InputStream.Peek();
                    if (xx == -1)
                    {
                        throw new NotImplementedException();
                    }
                    else
                    {
                        x = (char)xx;
                    }
                }while (currentReadtable.IsWhitespaceSyntax(x) && (this.context.InputStream.Read() != -1));
                if (x == ')')
                {
                    this.context.InputStream.Read();  // discard the close paren
                    return((CL.ReadSuppress == true)
                    ? new FinalReaderMacroStep()
                    : new FinalReaderMacroStep(CL.Reconc(head, tail)));
                }
                //else if (x == '.') {
                //    throw new NotImplementedException ();
                //}
                else
                {
                    object next = CL.Read(this.context.InputStream, true, null, true);  // recursive read
                    if (CL.ReadSuppress != true)
                    {
                        head = CL.Cons(next, head);
                    }
                }
            }
        }