public abstract class InputBuffer extends Object
A dynamic array is used to buffer up all the input characters. Normally, "k" characters are stored in the buffer. More characters may be stored during guess mode (testing syntactic predicate), or when LT(i>k) is referenced. Consumption of characters is deferred. In other words, reading the next character is not done by conume(), but deferred until needed by LA or LT.
CharQueue
Modifier and Type | Field and Description |
---|---|
protected int |
markerOffset |
protected int |
nMarkers |
protected int |
numToConsume |
protected CharQueue |
queue |
Constructor and Description |
---|
InputBuffer()
Create an input buffer
|
Modifier and Type | Method and Description |
---|---|
void |
commit()
This method updates the state of the input buffer so that
the text matched since the most recent mark() is no longer
held by the buffer.
|
void |
consume()
Mark another character for deferred consumption
|
abstract void |
fill(int amount)
Ensure that the input buffer is sufficiently full
|
String |
getLAChars() |
String |
getMarkedChars() |
boolean |
isMarked() |
char |
LA(int i)
Get a lookahead character
|
int |
mark()
Return an integer marker that can be used to rewind the buffer to
its current state.
|
void |
reset()
Reset the input buffer
|
void |
rewind(int mark)
Rewind the character buffer to a marker.
|
protected void |
syncConsume()
Sync up deferred consumption
|
protected int nMarkers
protected int markerOffset
protected int numToConsume
protected CharQueue queue
public void commit()
public void consume()
public abstract void fill(int amount) throws CharStreamException
CharStreamException
public String getLAChars()
public String getMarkedChars()
public boolean isMarked()
public char LA(int i) throws CharStreamException
CharStreamException
public int mark()
public void rewind(int mark)
mark
- Marker returned previously from mark()public void reset()
protected void syncConsume()