org.codehaus.groovy.syntax.lexer
Interface Lexer

All Known Implementing Classes:
LexerBase

public interface Lexer

The minimal interface provided by all Lexers.

Author:
Bob Mcwhirter, James Strachan, John Wilson, Chris Poirier

Method Summary
 char consume()
          Eats a single character from the input stream.
 void delegate(Lexer to)
          Delegates our duties to another Lexer.
 int getColumn()
          Returns the current column on that line.
 Lexer getDelegate()
          Gets the lexer that is actually doing the nextToken() work, if it isn't us.
 int getLine()
          Returns the current line number.
 Lexer getSource()
          Gets the lexer from which this lexer is obtaining characters.
 boolean isDelegated()
          Returns true if we are delegated.
 boolean isExternallySourced()
          Returns true if we have an external source.
 char la()
          Returns the next character, without consuming it.
 char la(int k)
          Returns the next kth character, without consuming any.
 Token nextToken()
          Finds and returns (consuming) the next token from the underlying stream.
 void reset()
          Resets a lexer for reuse.
 void setSource(Lexer source)
          Sets the source lexer.
 void undelegate()
          Retakes responsibility for our duties.
 void unsetSource()
          Unsets the source lexer.
 

Method Detail

getDelegate

public Lexer getDelegate()
Gets the lexer that is actually doing the nextToken() work, if it isn't us.


getSource

public Lexer getSource()
Gets the lexer from which this lexer is obtaining characters.


nextToken

public Token nextToken()
                throws ReadException,
                       LexerException
Finds and returns (consuming) the next token from the underlying stream. Returns null when out of tokens.

Throws:
ReadException
LexerException

reset

public void reset()
Resets a lexer for reuse.


delegate

public void delegate(Lexer to)
Delegates our duties to another Lexer.


undelegate

public void undelegate()
Retakes responsibility for our duties.


isDelegated

public boolean isDelegated()
Returns true if we are delegated.


setSource

public void setSource(Lexer source)
Sets the source lexer.


unsetSource

public void unsetSource()
Unsets the source lexer.


isExternallySourced

public boolean isExternallySourced()
Returns true if we have an external source.


getLine

public int getLine()
Returns the current line number.


getColumn

public int getColumn()
Returns the current column on that line.


la

public char la()
        throws LexerException,
               ReadException
Returns the next character, without consuming it.

Throws:
LexerException
ReadException

la

public char la(int k)
        throws LexerException,
               ReadException
Returns the next kth character, without consuming any.

Throws:
LexerException
ReadException

consume

public char consume()
             throws LexerException,
                    ReadException
Eats a single character from the input stream.

Throws:
LexerException
ReadException


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