org.codehaus.groovy.syntax.lexer
Class Lexer

java.lang.Object
  extended byorg.codehaus.groovy.syntax.lexer.Lexer

public class Lexer
extends java.lang.Object

Identifies and returns tokens from a source text. nextToken() is the primary entry point.

Author:
Bob Mcwhirter, James Strachan, John Wilson

Constructor Summary
Lexer(CharStream charStream)
          Initializes the Lexer from an opened CharStream.
 
Method Summary
protected  char consume()
          Eats a character from the input stream.
protected  void eol()
          Handles end-of-line processing.
 CharStream getCharStream()
          Returns the underlying CharStream.
protected  int getStartColumn()
          Returns the starting column of the current token.
protected  int getStartLine()
          Returns the starting line of the current token.
protected  char la()
          Returns the next character, without consuming it.
protected  char la(int k)
          Returns the next kth character, without consuming any.
protected  void mark()
          Saves information about the current position, for tracking token extents.
 Token nextToken()
          Finds and returns (and consumes) the next token from the underlying stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Lexer

public Lexer(CharStream charStream)
Initializes the Lexer from an opened CharStream.

Method Detail

getCharStream

public CharStream getCharStream()
Returns the underlying CharStream.


nextToken

public Token nextToken()
                throws ReadException,
                       LexerException
Finds and returns (and consumes) the next token from the underlying stream.

Throws:
ReadException
LexerException

eol

protected void eol()
Handles end-of-line processing.


mark

protected void mark()
Saves information about the current position, for tracking token extents.


getStartLine

protected int getStartLine()
Returns the starting line of the current token.


getStartColumn

protected int getStartColumn()
Returns the starting column of the current token.


la

protected char la()
           throws UnexpectedCharacterException,
                  ReadException
Returns the next character, without consuming it.

Throws:
UnexpectedCharacterException
ReadException

la

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

Throws:
UnexpectedCharacterException
ReadException

consume

protected char consume()
                throws UnexpectedCharacterException,
                       ReadException
Eats a character from the input stream.

Throws:
UnexpectedCharacterException
ReadException


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