org.codehaus.groovy.syntax.lexer
Class StringLexer

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

public class StringLexer
extends TextLexerBase

A Lexer for processing standard strings.

Author:
Chris Poirier

Field Summary
protected  boolean allowGStrings
           
protected  String delimiter
           
protected  boolean emptyString
           
protected  char watchFor
           
 
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
StringLexer()
           
 
Method Summary
 void allowGStrings(boolean allow)
          If set true, the filter will allow \\ and \$ to pass through unchanged.
 char consume()
          Eats a character from the input stream.
 void delimit(boolean delimit)
          Controls delimiter search.
protected  void finishUp()
          Eats our delimiter from the stream and marks us finished.
 char la(int k)
          Returns the next kth character, without consuming any.
 void setSource(Lexer source)
          Sets the source lexer and identifies and consumes the opening delimiter.
 Token undelegatedNextToken()
          Returns a single STRING, then null.
 void unsetSource()
          Unsets our source.
 
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, unexpected, unexpected, unexpected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delimiter

protected String delimiter

watchFor

protected char watchFor

allowGStrings

protected boolean allowGStrings

emptyString

protected boolean emptyString
Constructor Detail

StringLexer

public StringLexer()
Method Detail

allowGStrings

public void allowGStrings(boolean allow)
If set true, the filter will allow \\ and \$ to pass through unchanged. You should set this appropriately BEFORE setting source!


undelegatedNextToken

public Token undelegatedNextToken()
                           throws ReadException,
                                  LexerException
Returns a single STRING, then null. The STRING is all of the processed input. Backslashes are stripped, with the \r, \n, and \t converted appropriately.

Overrides:
undelegatedNextToken in class LexerBase
Throws:
ReadException
LexerException

delimit

public void delimit(boolean delimit)
Controls delimiter search. When turned on, the first thing we do is check for and eat our delimiter.

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

setSource

public void setSource(Lexer source)
Sets the source lexer and identifies and consumes the opening delimiter.

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

unsetSource

public void unsetSource()
Unsets our source.

Specified by:
unsetSource in interface Lexer
Overrides:
unsetSource 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 TextLexerBase
Throws:
LexerException
ReadException

consume

public char consume()
             throws LexerException,
                    ReadException
Eats a character from the input stream. Searches for the delimiter if delimited. 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

finishUp

protected void finishUp()
                 throws LexerException,
                        ReadException
Eats our delimiter from the stream and marks us finished.

Throws:
LexerException
ReadException


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