Changeset 8234


Ignore:
Timestamp:
12/07/04 19:28:16 (17 years ago)
Author:
piso
Message:

Work in progress.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/Primitives.java

    r8232 r8234  
    33 *
    44 * Copyright (C) 2002-2004 Peter Graves
    5  * $Id: Primitives.java,v 1.720 2004-12-07 18:12:45 piso Exp $
     5 * $Id: Primitives.java,v 1.721 2004-12-07 19:28:16 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    38523852                      "&optional input-stream eof-error-p eof-value recursive-p")
    38533853    {
    3854         public LispObject execute(LispObject first, LispObject second)
    3855             throws ConditionThrowable
    3856         {
    3857             Stream stream = checkCharacterInputStream(first);
    3858             boolean eofError = (second != NIL);
    3859             LispObject eofValue = NIL;
    3860             boolean recursive = false;
    3861             return stream.read(eofError, eofValue, recursive);
     3854        public LispObject execute() throws ConditionThrowable
     3855        {
     3856            return checkCharacterInputStream(_STANDARD_INPUT_.symbolValue()).read(true, NIL, false);
     3857        }
     3858        public LispObject execute(LispObject arg) throws ConditionThrowable
     3859        {
     3860            return inSynonymOf(arg).read(true, NIL, false);
     3861        }
     3862        public LispObject execute(LispObject first, LispObject second)
     3863            throws ConditionThrowable
     3864        {
     3865            return inSynonymOf(first).read(second != NIL, NIL, false);
    38623866        }
    38633867        public LispObject execute(LispObject first, LispObject second,
     
    38653869            throws ConditionThrowable
    38663870        {
    3867             Stream stream = checkCharacterInputStream(first);
    3868             boolean eofError = (second != NIL);
    3869             LispObject eofValue = third;
    3870             boolean recursive = false;
    3871             return stream.read(eofError, eofValue, recursive);
     3871            return inSynonymOf(first).read(second != NIL, third, false);
    38723872        }
    38733873        public LispObject execute(LispObject first, LispObject second,
     
    38753875            throws ConditionThrowable
    38763876        {
    3877             Stream stream = checkCharacterInputStream(first);
    3878             boolean eofError = (second != NIL);
    3879             LispObject eofValue = third;
    3880             boolean recursive = (fourth != NIL);
    3881             return stream.read(eofError, eofValue, recursive);
    3882         }
    3883         public LispObject execute(LispObject[] args) throws ConditionThrowable
    3884         {
    3885             int length = args.length;
    3886             if (length > 4)
    3887                 signal(new WrongNumberOfArgumentsException(this));
    3888             Stream stream =
    3889                 length > 0 ? checkCharacterInputStream(args[0]) : getStandardInput();
    3890             boolean eofError = length > 1 ? (args[1] != NIL) : true;
    3891             LispObject eofValue = length > 2 ? args[2] : NIL;
    3892             boolean recursive = length > 3 ? (args[3] != NIL) : false;
    3893             return stream.read(eofError, eofValue, recursive);
     3877            return inSynonymOf(first).read(second != NIL, third, fourth != NIL);
    38943878        }
    38953879    };
     
    39013885                      "&optional input-stream eof-error-p eof-value recursive-p")
    39023886    {
    3903         public LispObject execute(LispObject[] args) throws ConditionThrowable
    3904         {
    3905             int length = args.length;
    3906             if (length > 4)
    3907                 signal(new WrongNumberOfArgumentsException(this));
    3908             Stream stream =
    3909                 length > 0 ? checkCharacterInputStream(args[0]) : getStandardInput();
    3910             boolean eofError = length > 1 ? (args[1] != NIL) : true;
    3911             LispObject eofValue = length > 2 ? args[2] : NIL;
    3912             boolean recursive = length > 3 ? (args[3] != NIL) : false;
    3913             return stream.readPreservingWhitespace(eofError, eofValue,
    3914                                                    recursive,
    3915                                                    LispThread.currentThread());
    3916         }
    3917     };
    3918 
    3919     // ### read-char
    3920     // read-char &optional input-stream eof-error-p eof-value recursive-p => char
    3921     private static final Primitive READ_CHAR =
    3922         new Primitive("read-char",
    3923                       "&optional input-stream eof-error-p eof-value recursive-p")
    3924     {
    3925         public LispObject execute(LispObject arg) throws ConditionThrowable
    3926         {
    3927             return inSynonymOf(arg).readChar();
    3928         }
    3929         public LispObject execute(LispObject first, LispObject second)
    3930             throws ConditionThrowable
    3931         {
    3932             return inSynonymOf(first).readChar(second != NIL, NIL);
    3933         }
    3934         public LispObject execute(LispObject first, LispObject second,
    3935                                   LispObject third)
    3936             throws ConditionThrowable
    3937         {
    3938             return inSynonymOf(first).readChar(second != NIL, third);
    3939         }
    39403887        public LispObject execute(LispObject[] args) throws ConditionThrowable
    39413888        {
     
    39483895            LispObject eofValue = length > 2 ? args[2] : NIL;
    39493896            boolean recursive = length > 3 ? (args[3] != NIL) : false;
     3897            return stream.readPreservingWhitespace(eofError, eofValue,
     3898                                                   recursive,
     3899                                                   LispThread.currentThread());
     3900        }
     3901    };
     3902
     3903    // ### read-char
     3904    // read-char &optional input-stream eof-error-p eof-value recursive-p => char
     3905    private static final Primitive READ_CHAR =
     3906        new Primitive("read-char",
     3907                      "&optional input-stream eof-error-p eof-value recursive-p")
     3908    {
     3909        public LispObject execute() throws ConditionThrowable
     3910        {
     3911            return checkCharacterInputStream(_STANDARD_INPUT_.symbolValue()).readChar();
     3912        }
     3913        public LispObject execute(LispObject arg) throws ConditionThrowable
     3914        {
     3915            return inSynonymOf(arg).readChar();
     3916        }
     3917        public LispObject execute(LispObject first, LispObject second)
     3918            throws ConditionThrowable
     3919        {
     3920            return inSynonymOf(first).readChar(second != NIL, NIL);
     3921        }
     3922        public LispObject execute(LispObject first, LispObject second,
     3923                                  LispObject third)
     3924            throws ConditionThrowable
     3925        {
     3926            return inSynonymOf(first).readChar(second != NIL, third);
     3927        }
     3928        public LispObject execute(LispObject first, LispObject second,
     3929                                  LispObject third, LispObject fourth)
     3930            throws ConditionThrowable
     3931        {
     3932            return inSynonymOf(first).readChar(second != NIL, third);
     3933        }
     3934        public LispObject execute(LispObject[] args) throws ConditionThrowable
     3935        {
     3936            int length = args.length;
     3937            if (length > 4)
     3938                signal(new WrongNumberOfArgumentsException(this));
     3939            Stream stream =
     3940                length > 0 ? inSynonymOf(args[0]) : getStandardInput();
     3941            boolean eofError = length > 1 ? (args[1] != NIL) : true;
     3942            LispObject eofValue = length > 2 ? args[2] : NIL;
    39503943            return stream.readChar(eofError, eofValue);
    39513944        }
Note: See TracChangeset for help on using the changeset viewer.