antlr
Class CharScanner

java.lang.Object
  |
  +--antlr.CharScanner
All Implemented Interfaces:
TokenStream
Direct Known Subclasses:
ActionLexer, ActionLexer, ActionLexer, ANTLRLexer, ANTLRTokdefLexer, DebuggingCharScanner, PreprocessorLexer

public abstract class CharScanner
extends Object
implements TokenStream

Untamed:


Field Summary
protected  Token _returnToken
           
protected  boolean caseSensitive
           
protected  boolean caseSensitiveLiterals
           
protected  boolean commitToPath
          Used during filter mode to indicate that path is desired.
static char EOF_CHAR
          Enabled:
protected  ANTLRHashString hashString
           
protected  LexerSharedInputState inputState
           
protected  Hashtable literals
           
(package private) static char NO_CHAR
           
protected  boolean saveConsumedInput
           
protected  ANTLRStringBuffer text
           
protected  Class tokenObjectClass
           
protected  int traceDepth
          Used to keep track of indentdepth for traceIn/Out
 
Constructor Summary
CharScanner()
          Enabled:
CharScanner(InputBuffer cb)
          Enabled:
CharScanner(LexerSharedInputState sharedState)
          Enabled:
 
Method Summary
 void append(char c)
          Enabled:
 void append(String s)
          Enabled:
 void commit()
          Enabled:
 void consume()
          Enabled:
 void consumeUntil(BitSet set)
          Enabled: Consume chars until one matches the given set
 void consumeUntil(int c)
          Enabled: Consume chars until one matches the given char
 boolean getCaseSensitive()
          Enabled:
 boolean getCaseSensitiveLiterals()
          Enabled:
 int getColumn()
          Enabled:
 boolean getCommitToPath()
          Enabled:
 String getFilename()
          Enabled:
 InputBuffer getInputBuffer()
          Enabled:
 LexerSharedInputState getInputState()
          Enabled:
 int getLine()
          Enabled:
 String getText()
          Enabled: return a copy of the current text buffer
 Token getTokenObject()
          Enabled:
 char LA(int i)
          Enabled:
protected  Token makeToken(int t)
           
 int mark()
          Enabled:
 void match(BitSet b)
          Enabled:
 void match(char c)
          Enabled:
 void match(String s)
          Enabled:
 void matchNot(char c)
          Enabled:
 void matchRange(char c1, char c2)
          Enabled:
 void newline()
          Enabled:
 void panic()
          Enabled:
 void panic(String s)
          Enabled:
 void reportError(RecognitionException ex)
          Enabled: Parser error-reporting function can be overridden in subclass
 void reportError(String s)
          Enabled: Parser error-reporting function can be overridden in subclass
 void reportWarning(String s)
          Enabled: Parser warning-reporting function can be overridden in subclass
 void resetText()
          Enabled:
 void rewind(int pos)
          Enabled:
 void setCaseSensitive(boolean t)
          Enabled:
 void setColumn(int c)
          Enabled:
 void setCommitToPath(boolean commit)
          Enabled:
 void setFilename(String f)
          Enabled:
 void setInputState(LexerSharedInputState state)
          Enabled:
 void setLine(int line)
          Enabled:
 void setText(String s)
          Enabled:
 void setTokenObjectClass(String cl)
          Enabled:
 void tab()
          Enabled: advance the current column number by an appropriate amount.
 int testLiteralsTable(int ttype)
          Enabled:
 int testLiteralsTable(String text, int ttype)
          Enabled: Test the text passed in against the literals table Override this method to perform a different literals test This is used primarily when you want to test a portion of a token.
 char toLower(char c)
          Enabled:
 void traceIn(String rname)
          Enabled:
 void traceIndent()
          Enabled:
 void traceOut(String rname)
          Enabled:
 void uponEOF()
          Enabled: This method is called by YourLexer.nextToken() when the lexer has hit EOF condition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface antlr.TokenStream
nextToken
 

Field Detail

NO_CHAR

static final char NO_CHAR

EOF_CHAR

public static final char EOF_CHAR
Enabled:


text

protected ANTLRStringBuffer text

saveConsumedInput

protected boolean saveConsumedInput

tokenObjectClass

protected Class tokenObjectClass

caseSensitive

protected boolean caseSensitive

caseSensitiveLiterals

protected boolean caseSensitiveLiterals

literals

protected Hashtable literals

_returnToken

protected Token _returnToken

hashString

protected ANTLRHashString hashString

inputState

protected LexerSharedInputState inputState

commitToPath

protected boolean commitToPath
Used during filter mode to indicate that path is desired. A subsequent scan error will report an error as usual if acceptPath=true;


traceDepth

protected int traceDepth
Used to keep track of indentdepth for traceIn/Out

Constructor Detail

CharScanner

public CharScanner()
Enabled:


CharScanner

public CharScanner(InputBuffer cb)
Enabled:


CharScanner

public CharScanner(LexerSharedInputState sharedState)
Enabled:

Method Detail

append

public void append(char c)
Enabled:


append

public void append(String s)
Enabled:


commit

public void commit()
Enabled:


consume

public void consume()
             throws CharStreamException
Enabled:

CharStreamException

consumeUntil

public void consumeUntil(int c)
                  throws CharStreamException
Enabled: Consume chars until one matches the given char

CharStreamException

consumeUntil

public void consumeUntil(BitSet set)
                  throws CharStreamException
Enabled: Consume chars until one matches the given set

CharStreamException

getCaseSensitive

public boolean getCaseSensitive()
Enabled:


getCaseSensitiveLiterals

public final boolean getCaseSensitiveLiterals()
Enabled:


getColumn

public int getColumn()
Enabled:


setColumn

public void setColumn(int c)
Enabled:


getCommitToPath

public boolean getCommitToPath()
Enabled:


getFilename

public String getFilename()
Enabled:


getInputBuffer

public InputBuffer getInputBuffer()
Enabled:


getInputState

public LexerSharedInputState getInputState()
Enabled:


setInputState

public void setInputState(LexerSharedInputState state)
Enabled:


getLine

public int getLine()
Enabled:


getText

public String getText()
Enabled: return a copy of the current text buffer


getTokenObject

public Token getTokenObject()
Enabled:


LA

public char LA(int i)
        throws CharStreamException
Enabled:

CharStreamException

makeToken

protected Token makeToken(int t)

mark

public int mark()
Enabled:


match

public void match(char c)
           throws MismatchedCharException,
                  CharStreamException
Enabled:

MismatchedCharException
CharStreamException

match

public void match(BitSet b)
           throws MismatchedCharException,
                  CharStreamException
Enabled:

MismatchedCharException
CharStreamException

match

public void match(String s)
           throws MismatchedCharException,
                  CharStreamException
Enabled:

MismatchedCharException
CharStreamException

matchNot

public void matchNot(char c)
              throws MismatchedCharException,
                     CharStreamException
Enabled:

MismatchedCharException
CharStreamException

matchRange

public void matchRange(char c1,
                       char c2)
                throws MismatchedCharException,
                       CharStreamException
Enabled:

MismatchedCharException
CharStreamException

newline

public void newline()
Enabled:


tab

public void tab()
Enabled: advance the current column number by an appropriate amount. If you do not override this to specify how much to jump for a tab, then tabs are counted as one char. This method is called from consume().


panic

public void panic()
Enabled:


panic

public void panic(String s)
Enabled:


reportError

public void reportError(RecognitionException ex)
Enabled: Parser error-reporting function can be overridden in subclass


reportError

public void reportError(String s)
Enabled: Parser error-reporting function can be overridden in subclass


reportWarning

public void reportWarning(String s)
Enabled: Parser warning-reporting function can be overridden in subclass


resetText

public void resetText()
Enabled:


rewind

public void rewind(int pos)
Enabled:


setCaseSensitive

public void setCaseSensitive(boolean t)
Enabled:


setCommitToPath

public void setCommitToPath(boolean commit)
Enabled:


setFilename

public void setFilename(String f)
Enabled:


setLine

public void setLine(int line)
Enabled:


setText

public void setText(String s)
Enabled:


setTokenObjectClass

public void setTokenObjectClass(String cl)
Enabled:


testLiteralsTable

public int testLiteralsTable(int ttype)
Enabled:


testLiteralsTable

public int testLiteralsTable(String text,
                             int ttype)
Enabled: Test the text passed in against the literals table Override this method to perform a different literals test This is used primarily when you want to test a portion of a token.


toLower

public char toLower(char c)
Enabled:


traceIndent

public void traceIndent()
Enabled:


traceIn

public void traceIn(String rname)
             throws CharStreamException
Enabled:

CharStreamException

traceOut

public void traceOut(String rname)
              throws CharStreamException
Enabled:

CharStreamException

uponEOF

public void uponEOF()
             throws TokenStreamException,
                    CharStreamException
Enabled: This method is called by YourLexer.nextToken() when the lexer has hit EOF condition. EOF is NOT a character. This method is not called if EOF is reached during syntactic predicate evaluation or during evaluation of normal lexical rules, which presumably would be an IOException. This traps the "normal" EOF condition. uponEOF() is called after the complete evaluation of the previous token and only if your parser asks for another token beyond that last non-EOF token. You might want to throw token or char stream exceptions like: "Heh, premature eof" or a retry stream exception ("I found the end of this file, go back to referencing file").

TokenStreamException
CharStreamException


comments?