Package antlr
Class CharScanner
java.lang.Object
antlr.CharScanner
- All Implemented Interfaces:
TokenStream
- Direct Known Subclasses:
ActionLexer
,ActionLexer
,ActionLexer
,ActionLexer
,ANTLRLexer
,ANTLRTokdefLexer
,CodeLexer
,DebuggingCharScanner
,PreprocessorLexer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Token
protected boolean
protected boolean
protected boolean
Used during filter mode to indicate that path is desired.static final char
protected ANTLRHashString
protected LexerSharedInputState
protected Hashtable
(package private) static final char
protected boolean
protected int
Tab chars are handled by tab() according to this value; override method to do anything weird with tabs.protected ANTLRStringBuffer
protected Class
protected int
Used to keep track of indentdepth for traceIn/Out -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
append
(char c) void
void
commit()
void
consume()
void
consumeUntil
(int c) Consume chars until one matches the given charvoid
consumeUntil
(BitSet set) Consume chars until one matches the given setboolean
final boolean
int
boolean
int
getLine()
int
getText()
return a copy of the current text bufferchar
LA
(int i) protected Token
makeToken
(int t) int
mark()
void
match
(char c) void
void
void
matchNot
(char c) void
matchRange
(char c1, char c2) void
newline()
void
panic()
void
This method is executed by ANTLR internally when it detected an illegal state that cannot be recovered from.void
Parser error-reporting function can be overridden in subclassvoid
Parser error-reporting function can be overridden in subclassvoid
Parser warning-reporting function can be overridden in subclassvoid
void
rewind
(int pos) void
setCaseSensitive
(boolean t) void
setColumn
(int c) void
setCommitToPath
(boolean commit) void
void
void
setLine
(int line) void
setTabSize
(int size) void
void
void
tab()
advance the current column number by an appropriate amount according to tab size.int
testLiteralsTable
(int ttype) int
testLiteralsTable
(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
void
void
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 Details
-
NO_CHAR
static final char NO_CHAR- See Also:
-
EOF_CHAR
public static final char EOF_CHAR- See Also:
-
text
-
saveConsumedInput
protected boolean saveConsumedInput -
tokenObjectClass
-
caseSensitive
protected boolean caseSensitive -
caseSensitiveLiterals
protected boolean caseSensitiveLiterals -
literals
-
tabsize
protected int tabsizeTab chars are handled by tab() according to this value; override method to do anything weird with tabs. -
_returnToken
-
hashString
-
inputState
-
commitToPath
protected boolean commitToPathUsed 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 traceDepthUsed to keep track of indentdepth for traceIn/Out
-
-
Constructor Details
-
CharScanner
public CharScanner() -
CharScanner
-
-
Method Details
-
append
public void append(char c) -
append
-
commit
public void commit() -
consume
- Throws:
CharStreamException
-
consumeUntil
Consume chars until one matches the given char- Throws:
CharStreamException
-
consumeUntil
Consume chars until one matches the given set- Throws:
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
-
getInputBuffer
-
getInputState
-
getLine
public int getLine() -
getText
return a copy of the current text buffer -
getTokenObject
-
LA
- Throws:
CharStreamException
-
makeToken
-
mark
public int mark() -
match
-
match
-
match
-
matchNot
-
matchRange
-
newline
public void newline() -
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()- See Also:
-
panic
This method is executed by ANTLR internally when it detected an illegal state that cannot be recovered from. The default implementation of this method calls {@link java.lang.System.exit(int)} and writes directly to {@link java.lang.System.err)} , which is usually not appropriate when a translator is embedded into a larger application. It is highly recommended that this method be overridden to handle the error in a way appropriate for your application (e.g. throw an unchecked exception). -
reportError
Parser error-reporting function can be overridden in subclass -
reportError
Parser error-reporting function can be overridden in subclass -
reportWarning
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
-
setLine
public void setLine(int line) -
setText
-
setTokenObjectClass
-
testLiteralsTable
public int testLiteralsTable(int ttype) -
testLiteralsTable
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
- Throws:
CharStreamException
-
traceOut
- Throws:
CharStreamException
-
uponEOF
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").
-