|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.antlr.runtime.BaseRecognizer
org.antlr.runtime.Lexer
public abstract class Lexer
A lexer is recognizer that draws input symbols from a character stream. lexer grammars result in a subclass of this object. A Lexer object uses simplified match() and error recovery mechanisms in the interest of speed.
Field Summary | |
---|---|
protected CharStream |
input
Where is the lexer drawing characters from? |
Fields inherited from class org.antlr.runtime.BaseRecognizer |
---|
DEFAULT_TOKEN_CHANNEL, HIDDEN, INITIAL_FOLLOW_STACK_SIZE, MEMO_RULE_FAILED, MEMO_RULE_UNKNOWN, NEXT_TOKEN_RULE_NAME, state |
Constructor Summary | |
---|---|
Lexer()
|
|
Lexer(CharStream input)
|
|
Lexer(CharStream input,
RecognizerSharedState state)
|
Method Summary | |
---|---|
Token |
emit()
The standard method called to automatically emit a token at the outermost lexical rule. |
void |
emit(Token token)
Currently does not support multiple emits per nextToken invocation for efficiency reasons. |
java.lang.String |
getCharErrorDisplay(int c)
|
int |
getCharIndex()
What is the index of the current character of lookahead? |
int |
getCharPositionInLine()
|
CharStream |
getCharStream()
|
java.lang.String |
getErrorMessage(RecognitionException e,
java.lang.String[] tokenNames)
What error message should be generated for the various exception types? Not very object-oriented code, but I like having all error message generation within one method rather than spread among all of the exception classes. |
int |
getLine()
|
java.lang.String |
getSourceName()
Where are you getting tokens from? normally the implication will simply ask lexers input stream. |
java.lang.String |
getText()
Return the text matched so far for the current token or any text override. |
void |
match(int c)
|
void |
match(java.lang.String s)
|
void |
matchAny()
|
void |
matchRange(int a,
int b)
|
abstract void |
mTokens()
This is the lexer entry point that sets instance var 'token' |
Token |
nextToken()
Return a token from this source; i.e., match a token on the char stream. |
void |
recover(RecognitionException re)
Lexers can normally match any char in it's vocabulary after matching a token, so do the easy thing and just kill a character and hope it all works out. |
void |
reportError(RecognitionException e)
Report a recognition problem. |
void |
reset()
reset the parser's state; subclasses must rewinds the input stream |
void |
setCharStream(CharStream input)
Set the char stream and reset the lexer |
void |
setText(java.lang.String text)
Set the complete text of this token; it wipes any previous changes to the text. |
void |
skip()
Instruct the lexer to skip creating a token for current lexer rule and look for another token. |
void |
traceIn(java.lang.String ruleName,
int ruleIndex)
|
void |
traceOut(java.lang.String ruleName,
int ruleIndex)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected CharStream input
Constructor Detail |
---|
public Lexer()
public Lexer(CharStream input)
public Lexer(CharStream input, RecognizerSharedState state)
Method Detail |
---|
public void reset()
BaseRecognizer
reset
in class BaseRecognizer
public Token nextToken()
nextToken
in interface TokenSource
public void skip()
public abstract void mTokens() throws RecognitionException
RecognitionException
public void setCharStream(CharStream input)
public CharStream getCharStream()
public java.lang.String getSourceName()
TokenSource
getSourceName
in interface TokenSource
getSourceName
in class BaseRecognizer
public void emit(Token token)
public Token emit()
public void match(java.lang.String s) throws MismatchedTokenException
MismatchedTokenException
public void matchAny()
public void match(int c) throws MismatchedTokenException
MismatchedTokenException
public void matchRange(int a, int b) throws MismatchedRangeException
MismatchedRangeException
public int getLine()
public int getCharPositionInLine()
public int getCharIndex()
public java.lang.String getText()
public void setText(java.lang.String text)
public void reportError(RecognitionException e)
BaseRecognizer
reportError
in class BaseRecognizer
public java.lang.String getErrorMessage(RecognitionException e, java.lang.String[] tokenNames)
BaseRecognizer
getErrorMessage
in class BaseRecognizer
public java.lang.String getCharErrorDisplay(int c)
public void recover(RecognitionException re)
public void traceIn(java.lang.String ruleName, int ruleIndex)
public void traceOut(java.lang.String ruleName, int ruleIndex)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |