public class ForthStreamReader extends ForthReader
bufferSize, description, lineNumber, position| Constructor and Description |
|---|
ForthStreamReader(java.io.Reader reader,
java.lang.String title)
Initialise the reader with a given input stream and input
source description.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
charAt(int off)
Return the character at the given offset into the buffer or -1
if the character is unavailable.
|
void |
close()
Close the input stream.
|
int |
read()
Reads a single character.
|
boolean |
ready()
Determines whether this stream is ready to be read.
|
boolean |
refill()
Attempt to fill the input buffer from the input source, and
return true if successful.
|
ForthReader |
restoreInput(VM vm)
Restore the current input environment from the system stack.
|
void |
saveInput(VM vm)
Save the current input parameters on the system stack.
|
backup, getBase, getDescription, getLineNumber, getPosition, isEmpty, setLineNumber, setPosition, sizepublic ForthStreamReader(java.io.Reader reader,
java.lang.String title)
reader - the input reader to be used for input.title - the input source description to be used
in error reports.public int read()
throws java.io.IOException
ForthReaderread in class ForthReaderjava.io.IOException - when there is a problem reading the input
stream.public boolean ready()
throws java.io.IOException
ForthReaderready in class ForthReaderjava.io.IOException - If an I/O error occurspublic void close()
throws java.io.IOException
ForthReaderclose in class ForthReaderjava.io.IOExceptionprotected int charAt(int off)
ForthReadercharAt in class ForthReaderoff - the offset from the start of the buffer to obtain
a character.public void saveInput(VM vm)
save-input function.
Place all of the parameters on the data stack followed by the
number of parameters.
The mark interface is used if the reader supports it.saveInput in class ForthReadervm - the virtual machine to use when saving the current
input environment.public ForthReader restoreInput(VM vm)
restore-input function.
This is the counter part to the saveInput() method.
The top of the stack holds the number of parameters saved.
The mark interface is used if the reader supports it.restoreInput in class ForthReadervm - the virtual machine to recover input parameters
form.null if the input environment could not
be recovered.public boolean refill()
throws java.io.IOException
ForthReaderposition to zero,
set bufferSize to the number of bytes read,
and return true.
Receipt of a line containing no characters is considered
successful. If there is no input available return false.
This method is called by the Forth function refill.refill in class ForthReaderjava.io.IOException - if there is an error when reading the line.