org.codehaus.groovy.syntax.lexer
Class HereDocLexer

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

public class HereDocLexer
extends TextLexerBase

A Lexer for processing here docs. It reads a line at a time from the underlying stream (leaving the EOL for the next read), then offers that data for users.

Author:
Chris Poirier

Field Summary
protected  int consumed
           
protected  String data
           
protected  boolean last
           
protected  String marker
           
protected  boolean onmargin
           
 
Fields inherited from class org.codehaus.groovy.syntax.lexer.TextLexerBase
delimited, finished
 
Fields inherited from class org.codehaus.groovy.syntax.lexer.LexerBase
delegate, source, startColumn, startLine
 
Constructor Summary
HereDocLexer(String marker)
          Initializes the lexer to read up to (and including) the marker on a line by itself.
 
Method Summary
 char consume()
          Eats a character from the input stream.
 void delimit(boolean delimit)
          Sets delimiting on.
 char la(int k)
          Returns the next kth character, without consuming any.
protected  void refill()
          Reads the next line from the underlying stream.
 void setSource(Lexer source)
          Sets the source lexer and sets the lexer running.
 void unsetSource()
          Unsets the source lexer.
 
Methods inherited from class org.codehaus.groovy.syntax.lexer.TextLexerBase
finish, isDelimited, isFinished, restart
 
Methods inherited from class org.codehaus.groovy.syntax.lexer.LexerBase
delegate, getColumn, getDelegate, getLine, getSource, getStartColumn, getStartLine, isDelegated, isExternallySourced, la, mark, nextToken, readEOL, readEOL, reset, symbol, symbol, tokenizeEOL, undelegate, undelegatedNextToken, unexpected, unexpected, unexpected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

marker

protected String marker

onmargin

protected boolean onmargin

data

protected String data

consumed

protected int consumed

last

protected boolean last
Constructor Detail

HereDocLexer

public HereDocLexer(String marker)
Initializes the lexer to read up to (and including) the marker on a line by itself.

Method Detail

setSource

public void setSource(Lexer source)
Sets the source lexer and sets the lexer running.

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

unsetSource

public void unsetSource()
Unsets the source lexer.

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

delimit

public void delimit(boolean delimit)
Sets delimiting on. The first thing we to is check for and eat our delimiter.

Specified by:
delimit in interface Delimiter
Overrides:
delimit in class TextLexerBase

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 TextLexerBase
Throws:
LexerException
ReadException

consume

public char consume()
             throws LexerException,
                    ReadException
Eats a character from the input stream. Searches for the delimiter if filtered. Note that turning delimiting on also checks if we are at the delimiter, so if we aren't finished, there is something to consume.

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

refill

protected void refill()
               throws LexerException,
                      ReadException
Reads the next line from the underlying stream. If delimited, checks for the marker. We don't update finished here, though, as that would prevent any buffered data from being read.

Throws:
LexerException
ReadException


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