|
|||||||||||
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 k th 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 TokenStream
ReadException
- If an error occurs attempting to lookahead
a token.
SyntaxException
TokenStream.la(int)
public Token la(int k) throws ReadException, SyntaxException
k
th token in the stream without consuming
it (or any other unconsumed tokens).
la
in interface TokenStream
k
- Number of token to look ahead.
k
th 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 TokenStream
type
- The token type.
ReadException
- If an error occurs attempting to consume
a token.
SyntaxException
public Token consume() throws ReadException, SyntaxException
ReadException
SyntaxException
public void checkpoint()
restore()
ing later.
checkpoint
in interface TokenStream
public void restore()
checkpoint()
.
restore
in interface TokenStream
public boolean atEnd(boolean ignoringWhitespace)
atEnd
in interface TokenStream
public boolean atEnd()
atEnd(true)
.
atEnd
in interface TokenStream
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |