org.codehaus.groovy.syntax
Interface TokenStream

All Known Implementing Classes:
AbstractTokenStream

public interface TokenStream

Provides a stream of lexer tokens for use by (primarily) the parsing systems.


Method Summary
 boolean atEnd()
          Returns true if the stream is out of tokens.
 boolean atEnd(boolean ignoringWhitespace)
          Returns true if the stream is out of tokens, possibly ignoring trailing whitespace.
 void checkpoint()
          Checkpoints a point in the stream that we can go back to
 Token consume(int type)
          Consumes the next token.
 java.lang.String getSourceLocator()
          Returns a description of the source location (typically a file path).
 Token la()
          Looks-ahead to the next token.
 Token la(int k)
          Looks-ahead to the kth token.
 void restore()
          Restores to the previous checkpoint
 

Method Detail

la

public Token la()
         throws ReadException,
                SyntaxException
Looks-ahead to the next token.

This method is equivalent to la(1).

Returns:
The next token or null if no more tokens available.
Throws:
ReadException - If an error occurs attempting to lookahead a token.
SyntaxException
See Also:
la(int)

la

public Token la(int k)
         throws ReadException,
                SyntaxException
Looks-ahead to the kth token.

Parameters:
k - Number of token to look ahead.
Returns:
the kth token or null if no more tokens available.
Throws:
ReadException - If an error occurs attempting to lookahead a token.
SyntaxException

consume

public Token consume(int type)
              throws ReadException,
                     SyntaxException
Consumes the next token.

Parameters:
type - The token type.
Returns:
The consumed token or null if no more tokens available.
Throws:
ReadException - If an error occurs attempting to consume a token.
SyntaxException

getSourceLocator

public java.lang.String getSourceLocator()
Returns a description of the source location (typically a file path).


checkpoint

public void checkpoint()
Checkpoints a point in the stream that we can go back to


restore

public void restore()
Restores to the previous checkpoint


atEnd

public boolean atEnd(boolean ignoringWhitespace)
Returns true if the stream is out of tokens, possibly ignoring trailing whitespace.


atEnd

public boolean atEnd()
Returns true if the stream is out of tokens.



Copyright © 2003-2004 The Codehaus. All Rights Reserved.