public class NestingAwareTokenIterator extends java.lang.Object implements java.util.Iterator<IToken>
Constructor and Description |
---|
NestingAwareTokenIterator(java.util.List<IToken> tokens,
int startPosition,
java.util.List<ETokenType> openingTypes,
java.util.List<ETokenType> closingTypes)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getCurrentIndex()
Returns the index of the current token, i.e.
|
int |
getNestingDepth()
Returns the depth of the current nesting.
|
boolean |
hasNext() |
boolean |
isTopLevel()
Returns
true if the last token returned by next() is a
top-level token. |
IToken |
next() |
void |
remove() |
public NestingAwareTokenIterator(java.util.List<IToken> tokens, int startPosition, java.util.List<ETokenType> openingTypes, java.util.List<ETokenType> closingTypes)
tokens
- the stream over which to iterate.startPosition
- the index of the first token that should be returned by the
iterator.openingTypes
- the list of tokens that open an new nesting level.closingTypes
- the list of tokens that close a nesting level. Each entry must
correspond to the entry of openingTypes at the same position.public boolean isTopLevel()
true
if the last token returned by next()
is a
top-level token. Opening/closing tokens are never top-level. In case
opening/closing tokens are not balanced, returns true
for
superfluous closing tokens and tokens thereafter.public int getNestingDepth()
public int getCurrentIndex()