Changeset 4042


Ignore:
Timestamp:
09/24/03 22:50:56 (19 years ago)
Author:
piso
Message:

READ-CHAR, UNREAD-CHAR

File:
1 edited

Legend:

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

    r4032 r4042  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Primitives.java,v 1.434 2003-09-23 16:32:04 piso Exp $
     5 * $Id: Primitives.java,v 1.435 2003-09-24 22:50:56 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    38203820    };
    38213821
     3822    // ### read
    38223823    // read &optional input-stream eof-error-p eof-value recursive-p => object
    38233824    private static final Primitive READ = new Primitive("read") {
     
    38333834            boolean recursive = length > 3 ? (args[3] != NIL) : false;
    38343835            return stream.read(eofError, eofValue, recursive);
     3836        }
     3837    };
     3838
     3839    // ### read-char
     3840    // read-char &optional input-stream eof-error-p eof-value recursive-p => char
     3841    private static final Primitive READ_CHAR = new Primitive("read-char") {
     3842        public LispObject execute(LispObject[] args) throws ConditionThrowable
     3843        {
     3844            int length = args.length;
     3845            if (length > 4)
     3846                throw new ConditionThrowable(new WrongNumberOfArgumentsException(this));
     3847            CharacterInputStream stream =
     3848                length > 0 ? checkInputStream(args[0]) : getStandardInput();
     3849            boolean eofError = length > 1 ? (args[1] != NIL) : true;
     3850            LispObject eofValue = length > 2 ? args[2] : NIL;
     3851            boolean recursive = length > 3 ? (args[3] != NIL) : false;
     3852            return stream.readChar(eofError, eofValue);
     3853        }
     3854    };
     3855
     3856    // ### unread-char
     3857    // unread-char character &optional input-stream => nil
     3858    private static final Primitive UNREAD_CHAR = new Primitive("unread-char") {
     3859        public LispObject execute(LispObject[] args) throws ConditionThrowable
     3860        {
     3861            int length = args.length;
     3862            if (length < 1)
     3863                throw new ConditionThrowable(new WrongNumberOfArgumentsException(this));
     3864            CharacterInputStream stream =
     3865                length > 1 ? checkInputStream(args[1]) : getStandardInput();
     3866            return stream.unreadChar(checkCharacter(args[0]));
    38353867        }
    38363868    };
Note: See TracChangeset for help on using the changeset viewer.