Methods Summary |
---|
public char | LA(int i)Get a lookahead character
fill(i);
return queue.elementAt(markerOffset + i - 1);
|
public 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. So, you either do a mark/rewind for
failed predicate or mark/commit to keep on parsing without
rewinding the input.
nMarkers--;
|
public void | consume()Mark another character for deferred consumption
numToConsume++;
|
public abstract void | fill(int amount)Ensure that the input buffer is sufficiently full
|
public java.lang.String | getLAChars()
StringBuffer la = new StringBuffer();
for (int i = markerOffset; i < queue.nbrEntries; i++)
la.append(queue.elementAt(i));
return la.toString();
|
public java.lang.String | getMarkedChars()
StringBuffer marked = new StringBuffer();
for (int i = 0; i < markerOffset; i++)
marked.append(queue.elementAt(i));
return marked.toString();
|
public boolean | isMarked()
return (nMarkers != 0);
|
public int | mark()Return an integer marker that can be used to rewind the buffer to
its current state.
syncConsume();
nMarkers++;
return markerOffset;
|
public void | reset()Reset the input buffer
nMarkers = 0;
markerOffset = 0;
numToConsume = 0;
queue.reset();
|
public void | rewind(int mark)Rewind the character buffer to a marker.
syncConsume();
markerOffset = mark;
nMarkers--;
|
protected void | syncConsume()Sync up deferred consumption
while (numToConsume > 0) {
if (nMarkers > 0) {
// guess mode -- leave leading characters and bump offset.
markerOffset++;
}
else {
// normal mode -- remove first character
queue.removeFirst();
}
numToConsume--;
}
|