// Copyright (c) 1996-2002 Brian D. Carlstrom

package bdc.scheme.procedure;

import bdc.scheme.Scheme;
import bdc.scheme.SchemeException;
import bdc.scheme.Stack;
import bdc.scheme.exception.ParseException;
import bdc.scheme.expression.Procedure0;
import bdc.util.Constants;
import java.io.IOException;

/**
    (char-ready&34;) (char-ready&34; x)
*/
public class CharReady extends Procedure0
{

    public Object apply0 (Stack stack) throws SchemeException
    {
        try {
            stack.addElement(stack.currentInputPort);
            return apply1(stack);
        }
        finally {
            stack.inUse -= 1;
        }
    }

    public Object apply1 (Stack stack) throws SchemeException
    {
        try {
            Object o1 = stack.array[stack.inUse-1];
            return Constants.getBoolean(Scheme.pushbackReader(o1,this).ready());
        }
        catch (IOException ioe) {
            throw new ParseException(this.toString(),
                                     0,
                                     ioe.toString());
        }
    }
}

