org.codehaus.groovy.syntax.lexer
Class GroovyExpressionLexer

java.lang.Object
  extended byorg.codehaus.groovy.syntax.lexer.LexerBase
      extended byorg.codehaus.groovy.syntax.lexer.GroovyLexerBase
          extended byorg.codehaus.groovy.syntax.lexer.GroovyExpressionLexer
All Implemented Interfaces:
Delimiter, Lexer

public class GroovyExpressionLexer
extends GroovyLexerBase
implements Delimiter

Lexes Groovy, counting braces. Considers itself at end of stream when the } count exceeds the { count.

Author:
Chris Poirier

Field Summary
protected  int balance
           
protected  boolean delimited
           
protected  boolean finished
           
 
Fields inherited from class org.codehaus.groovy.syntax.lexer.GroovyLexerBase
gstringLexer, stringLexer
 
Fields inherited from class org.codehaus.groovy.syntax.lexer.LexerBase
delegate, source, startColumn, startLine
 
Constructor Summary
GroovyExpressionLexer()
           
 
Method Summary
 char consume()
          Eats a character from the input stream.
 void delegate(Lexer to)
          Delegates our duties to another Lexer.
 void delimit(boolean delimited)
          Turns delimiting on or off.
protected  void finish()
          Stops the lexer stream.
 boolean isDelimited()
          Returns true if the lexer is applying its delimiter policy.
 boolean isFinished()
          Returns true if the lexer stream is dry.
 char la(int k)
          Returns the next kth character, without consuming any.
 Token nextToken()
          Finds and returns (and consumes) the next token from the underlying stream.
protected  void restart()
          Restarts the lexer stream after a finish() and some intevening act (like a new source).
 void undelegate()
          Retakes responsibility for our duties.
 
Methods inherited from class org.codehaus.groovy.syntax.lexer.LexerBase
getColumn, getDelegate, getLine, getSource, getStartColumn, getStartLine, isDelegated, isExternallySourced, la, mark, readEOL, readEOL, reset, setSource, symbol, symbol, tokenizeEOL, undelegatedNextToken, unexpected, unexpected, unexpected, unsetSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delimited

protected boolean delimited

finished

protected boolean finished

balance

protected int balance
Constructor Detail

GroovyExpressionLexer

public GroovyExpressionLexer()
Method Detail

nextToken

public Token nextToken()
                throws ReadException,
                       LexerException
Finds and returns (and consumes) the next token from the underlying stream. Returns null when out of tokens. We let the GroovyLexerBase version deal with delegation stuff.

Specified by:
nextToken in interface Lexer
Overrides:
nextToken in class GroovyLexerBase
Throws:
ReadException
LexerException

delimit

public void delimit(boolean delimited)
Turns delimiting on or off. This should affect la() and consume(). However, once the delimiter has been reached, this routine should have no effect.

Specified by:
delimit in interface Delimiter

isDelimited

public boolean isDelimited()
Returns true if the lexer is applying its delimiter policy.

Specified by:
isDelimited in interface Delimiter

isFinished

public boolean isFinished()
Returns true if the lexer stream is dry.

Specified by:
isFinished in interface Delimiter

restart

protected void restart()
Restarts the lexer stream after a finish() and some intevening act (like a new source).


finish

protected void finish()
Stops the lexer stream.


delegate

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

Specified by:
delegate in interface Lexer
Overrides:
delegate in class LexerBase

undelegate

public void undelegate()
Retakes responsibility for our duties.

Specified by:
undelegate in interface Lexer
Overrides:
undelegate in class LexerBase

la

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

Specified by:
la in interface Lexer
Overrides:
la in class LexerBase
Throws:
LexerException
ReadException

consume

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

Specified by:
consume in interface Lexer
Overrides:
consume in class LexerBase
Throws:
LexerException
ReadException


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