public class TokenStream extends java.lang.Object
Constructor and Description |
---|
TokenStream(java.util.List<IToken> tokens,
int position)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
advancePosition(int increment)
Advances the position of the stream by the given increment.
|
int |
getPosition()
Returns the current position in the stream.
|
java.util.List<IToken> |
getTokens() |
java.util.List<IToken> |
getTokensSince(int startPosition)
Returns a view of the tokens in between the given position (inclusive) and
the current position (exclusive).
|
boolean |
isAtBeginning()
Returns
true if the steam is positioned on the first token. |
boolean |
isExhausted()
Returns true if the stream is positioned past the last token.
|
IToken |
moveBack()
Moves the stream's position back by one token and returns the token at that
position or
null if the stream was already at the beginning. |
IToken |
next()
Advances the stream by one token.
|
IToken |
peekBackward()
Returns the token before the current one or
null if the stream
is at the beginning. |
IToken |
peekCurrent()
Returns the current token or
null if the stream is exhausted. |
void |
setPosition(int position)
Sets the position of the stream to the given one.
|
public TokenStream(java.util.List<IToken> tokens, int position)
public void setPosition(int position)
public void advancePosition(int increment)
public boolean isAtBeginning()
true
if the steam is positioned on the first token.public boolean isExhausted()
public java.util.List<IToken> getTokensSince(int startPosition)
public IToken next()
null
if the stream was already exhausted at that time.public IToken peekBackward()
null
if the stream
is at the beginning.public IToken peekCurrent()
null
if the stream is exhausted.public int getPosition()
setPosition(int)
.