|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.codehaus.groovy.syntax.AbstractTokenStream
Provides the common code for implementations.
TokenStream
| Field Summary | |
private int |
avail
|
private Token[] |
buf
|
private int |
checkpoint_avail
|
private int |
checkpoint_first
|
private int |
first
|
private java.lang.String |
sourceLocator
|
| Constructor Summary | |
AbstractTokenStream()
Default constructor. |
|
AbstractTokenStream(java.lang.String sourceLocator)
Initializes the stream with information about the source. |
|
| Method Summary | |
boolean |
atEnd()
A synonym for atEnd(true). |
boolean |
atEnd(boolean ignoringWhitespace)
Returns true if the stream is out of tokens. |
void |
checkpoint()
Saves the look-ahead state for restore()ing later. |
Token |
consume()
Removes and returns the first token in the stream, provided it isn't the EOF. |
Token |
consume(int type)
Removes and returns the first token in the stream, provided it matches the specified type. |
java.lang.String |
getSourceLocator()
Returns a description of the source (typically a file name). |
Token |
la()
Returns the next token in the stream without consuming it. |
Token |
la(int k)
Returns the kth token in the stream without consuming
it (or any other unconsumed tokens). |
protected abstract Token |
nextToken()
Implemented by concrete subtypes, provides access to the next token in the underlying stream. |
void |
restore()
Restores the look-ahead state saved by checkpoint(). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private Token[] buf
private int first
private int avail
private int checkpoint_first
private int checkpoint_avail
private java.lang.String sourceLocator
| Constructor Detail |
public AbstractTokenStream()
public AbstractTokenStream(java.lang.String sourceLocator)
| Method Detail |
public java.lang.String getSourceLocator()
getSourceLocator in interface TokenStream
protected abstract Token nextToken()
throws ReadException,
SyntaxException
ReadException
SyntaxException
public Token la()
throws ReadException,
SyntaxException
la in interface TokenStreamReadException - If an error occurs attempting to lookahead
a token.
SyntaxExceptionTokenStream.la(int)
public Token la(int k)
throws ReadException,
SyntaxException
kth token in the stream without consuming
it (or any other unconsumed tokens).
la in interface TokenStreamk - Number of token to look ahead.
kth token or null if no
more tokens available.
ReadException - If an error occurs attempting to lookahead
a token.
SyntaxException
public Token consume(int type)
throws ReadException,
SyntaxException
consume in interface TokenStreamtype - The token type.
ReadException - If an error occurs attempting to consume
a token.
SyntaxException
public Token consume()
throws ReadException,
SyntaxException
ReadException
SyntaxExceptionpublic void checkpoint()
restore()ing later.
checkpoint in interface TokenStreampublic void restore()
checkpoint().
restore in interface TokenStreampublic boolean atEnd(boolean ignoringWhitespace)
atEnd in interface TokenStreampublic boolean atEnd()
atEnd(true).
atEnd in interface TokenStream
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||