antlr
Class CharScanner

java.lang.Object
  |
  +--antlr.CharScanner
All Implemented Interfaces:
antlr.TokenStream
Direct Known Subclasses:
JavaLexer

public abstract class CharScanner
extends java.lang.Object
implements antlr.TokenStream


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
           
protected  antlr.ANTLRHashString hashString
           
protected  LexerSharedInputState inputState
           
protected  java.util.Hashtable literals
           
(package private) static char NO_CHAR
           
protected  boolean saveConsumedInput
           
protected  int tabsize
          Tab chars are handled by tab() according to this value; override method to do anything weird with tabs.
protected  antlr.ANTLRStringBuffer text
           
protected  java.lang.Class tokenObjectClass
           
protected  int traceDepth
          Used to keep track of indentdepth for traceIn/Out
 
Constructor Summary
CharScanner()
           
CharScanner(antlr.InputBuffer cb)
           
CharScanner(LexerSharedInputState sharedState)
           
 
Method Summary
 void append(char c)
           
 void append(java.lang.String s)
           
 void commit()
           
 void consume()
           
 void consumeUntil(antlr.collections.impl.BitSet set)
          Consume chars until one matches the given set
 void consumeUntil(int c)
          Consume chars until one matches the given char
 boolean getCaseSensitive()
           
 boolean getCaseSensitiveLiterals()
           
 int getColumn()
           
 boolean getCommitToPath()
           
 java.lang.String getFilename()
           
 antlr.InputBuffer getInputBuffer()
           
 LexerSharedInputState getInputState()
           
 int getLine()
           
 int getTabSize()
           
 java.lang.String getText()
          return a copy of the current text buffer
 Token getTokenObject()
           
 char LA(int i)
           
protected  Token makeToken(int t)
           
 int mark()
           
 void match(antlr.collections.impl.BitSet b)
           
 void match(char c)
           
 void match(java.lang.String s)
           
 void matchNot(char c)
           
 void matchRange(char c1, char c2)
           
 void newline()
          Modified newline by Mohammed Imran
 void panic()
           
 void panic(java.lang.String s)
           
 void reportError(antlr.RecognitionException ex)
          Parser error-reporting function can be overridden in subclass
 void reportError(java.lang.String s)
          Parser error-reporting function can be overridden in subclass
 void reportWarning(java.lang.String s)
          Parser warning-reporting function can be overridden in subclass
 void resetText()
           
 void rewind(int pos)
           
 void setCaseSensitive(boolean t)
           
 void setColumn(int c)
           
 void setCommitToPath(boolean commit)
           
 void setFilename(java.lang.String f)
           
 void setInputState(LexerSharedInputState state)
           
 void setLine(int line)
           
 void setTabSize(int size)
           
 void setText(java.lang.String s)
           
 void setTokenObjectClass(java.lang.String cl)
           
 void tab()
          advance the current column number by an appropriate amount according to tab size.
 int testLiteralsTable(int ttype)
           
 int testLiteralsTable(java.lang.String text, int ttype)
          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)
           
 void traceIn(java.lang.String rname)
           
 void traceIndent()
           
 void traceOut(java.lang.String rname)
           
 void uponEOF()
          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
See Also:
Constant Field Values

EOF_CHAR

public static final char EOF_CHAR
See Also:
Constant Field Values

text

protected antlr.ANTLRStringBuffer text

saveConsumedInput

protected boolean saveConsumedInput

tokenObjectClass

protected java.lang.Class tokenObjectClass

caseSensitive

protected boolean caseSensitive

caseSensitiveLiterals

protected boolean caseSensitiveLiterals

literals

protected java.util.Hashtable literals

tabsize

protected int tabsize
Tab chars are handled by tab() according to this value; override method to do anything weird with tabs.


_returnToken

protected Token _returnToken

hashString

protected antlr.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()

CharScanner

public CharScanner(antlr.InputBuffer cb)

CharScanner

public CharScanner(LexerSharedInputState sharedState)
Method Detail

append

public void append(char c)

append

public void append(java.lang.String s)

commit

public void commit()

consume

public void consume()
             throws antlr.CharStreamException
antlr.CharStreamException

consumeUntil

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

antlr.CharStreamException

consumeUntil

public void consumeUntil(antlr.collections.impl.BitSet set)
                  throws antlr.CharStreamException
Consume chars until one matches the given set

antlr.CharStreamException

getCaseSensitive

public boolean getCaseSensitive()

getCaseSensitiveLiterals

public final boolean getCaseSensitiveLiterals()

getColumn

public int getColumn()

setColumn

public void setColumn(int c)

getCommitToPath

public boolean getCommitToPath()

getFilename

public java.lang.String getFilename()

getInputBuffer

public antlr.InputBuffer getInputBuffer()

getInputState

public LexerSharedInputState getInputState()

setInputState

public void setInputState(LexerSharedInputState state)

getLine

public int getLine()

getText

public java.lang.String getText()
return a copy of the current text buffer


getTokenObject

public Token getTokenObject()

LA

public char LA(int i)
        throws antlr.CharStreamException
antlr.CharStreamException

makeToken

protected Token makeToken(int t)

mark

public int mark()

match

public void match(char c)
           throws antlr.MismatchedCharException,
                  antlr.CharStreamException
antlr.MismatchedCharException
antlr.CharStreamException

match

public void match(antlr.collections.impl.BitSet b)
           throws antlr.MismatchedCharException,
                  antlr.CharStreamException
antlr.MismatchedCharException
antlr.CharStreamException

match

public void match(java.lang.String s)
           throws antlr.MismatchedCharException,
                  antlr.CharStreamException
antlr.MismatchedCharException
antlr.CharStreamException

matchNot

public void matchNot(char c)
              throws antlr.MismatchedCharException,
                     antlr.CharStreamException
antlr.MismatchedCharException
antlr.CharStreamException

matchRange

public void matchRange(char c1,
                       char c2)
                throws antlr.MismatchedCharException,
                       antlr.CharStreamException
antlr.MismatchedCharException
antlr.CharStreamException

newline

public void newline()
Modified newline by Mohammed Imran


tab

public void tab()
advance the current column number by an appropriate amount according to tab size. This method is called from consume().


setTabSize

public void setTabSize(int size)

getTabSize

public int getTabSize()

panic

public void panic()

panic

public void panic(java.lang.String s)

reportError

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


reportError

public void reportError(java.lang.String s)
Parser error-reporting function can be overridden in subclass


reportWarning

public void reportWarning(java.lang.String s)
Parser warning-reporting function can be overridden in subclass


resetText

public void resetText()

rewind

public void rewind(int pos)

setCaseSensitive

public void setCaseSensitive(boolean t)

setCommitToPath

public void setCommitToPath(boolean commit)

setFilename

public void setFilename(java.lang.String f)

setLine

public void setLine(int line)

setText

public void setText(java.lang.String s)

setTokenObjectClass

public void setTokenObjectClass(java.lang.String cl)

testLiteralsTable

public int testLiteralsTable(int ttype)

testLiteralsTable

public int testLiteralsTable(java.lang.String text,
                             int ttype)
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)

traceIndent

public void traceIndent()

traceIn

public void traceIn(java.lang.String rname)
             throws antlr.CharStreamException
antlr.CharStreamException

traceOut

public void traceOut(java.lang.String rname)
              throws antlr.CharStreamException
antlr.CharStreamException

uponEOF

public void uponEOF()
             throws antlr.TokenStreamException,
                    antlr.CharStreamException
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").

antlr.TokenStreamException
antlr.CharStreamException