public class ForthTerminalReader extends ForthReader
bufferSize, description, lineNumber, position
Constructor and Description |
---|
ForthTerminalReader(VM vm)
Initialise the reader, using the standard input stream for
input and identifying the input source as "Terminal".
|
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, size
public ForthTerminalReader(VM vm)
vm
- the Virtual Machine for which the input is being
processed.public boolean ready() throws java.io.IOException
ForthReader
ready
in class ForthReader
java.io.IOException
- If an I/O error occurspublic int read() throws java.io.IOException
read
in class ForthReader
java.io.IOException
- when there is a problem reading the input
stream.public void close() throws java.io.IOException
ForthReader
close
in class ForthReader
java.io.IOException
protected int charAt(int off)
ForthReader
charAt
in class ForthReader
off
- 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 ForthReader
vm
- 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 ForthReader
vm
- the virtual machine to recover input parameters
form.null
if the input environment could not
be recovered.public boolean refill() throws java.io.IOException
ForthReader
position
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 ForthReader
java.io.IOException
- if there is an error when reading the line.