public abstract class Lexer extends Recognizer<Integer,LexerATNSimulator> implements TokenSource
| Modifier and Type | Field and Description | 
|---|---|
int | 
_channel
The channel number for the current token 
 | 
protected TokenFactory<?> | 
_factory
How to create token objects 
 | 
boolean | 
_hitEOF
Once we see EOF on char stream, next token will be EOF. 
 | 
CharStream | 
_input  | 
int | 
_mode  | 
IntegerStack | 
_modeStack  | 
String | 
_text
You can set the text for the current token to override what is in
  the input char buffer. 
 | 
Token | 
_token
The goal of all lexer rules/methods is to create a token object. 
 | 
protected Pair<TokenSource,CharStream> | 
_tokenFactorySourcePair  | 
int | 
_tokenStartCharIndex
What character index in the stream did the current token start at?
  Needed, for example, to get the text for current token. 
 | 
int | 
_tokenStartCharPositionInLine
The character position of first character within the line 
 | 
int | 
_tokenStartLine
The line on which the first character of the token resides 
 | 
int | 
_type
The token type for the current token 
 | 
static int | 
DEFAULT_MODE  | 
static int | 
DEFAULT_TOKEN_CHANNEL  | 
static int | 
HIDDEN  | 
static int | 
MAX_CHAR_VALUE  | 
static int | 
MIN_CHAR_VALUE  | 
static int | 
MORE  | 
static int | 
SKIP  | 
_interp, EOF| Constructor and Description | 
|---|
Lexer()  | 
Lexer(CharStream input)  | 
| Modifier and Type | Method and Description | 
|---|---|
Token | 
emit()
The standard method called to automatically emit a token at the
  outermost lexical rule. 
 | 
void | 
emit(Token token)
By default does not support multiple emits per nextToken invocation
  for efficiency reasons. 
 | 
Token | 
emitEOF()  | 
List<? extends Token> | 
getAllTokens()
Return a list of all Token objects in input char stream. 
 | 
int | 
getChannel()  | 
String | 
getCharErrorDisplay(int c)  | 
int | 
getCharIndex()
What is the index of the current character of lookahead? 
 | 
int | 
getCharPositionInLine()  | 
String | 
getErrorDisplay(int c)  | 
String | 
getErrorDisplay(String s)  | 
CharStream | 
getInputStream()
From what character stream was this token created?  You don't have to
  implement but it's nice to know where a Token comes from if you have
  include files etc... 
 | 
int | 
getLine()  | 
String[] | 
getModeNames()  | 
String | 
getSourceName()
Where are you getting tokens from? normally the implication will simply
  ask lexers input stream. 
 | 
String | 
getText()
Return the text matched so far for the current token or any
  text override. 
 | 
Token | 
getToken()
Override if emitting multiple tokens. 
 | 
TokenFactory<? extends Token> | 
getTokenFactory()
Gets the factory used for constructing tokens. 
 | 
String[] | 
getTokenNames()
Used to print out token names like ID during debugging and
  error reporting. 
 | 
int | 
getType()  | 
void | 
mode(int m)  | 
void | 
more()  | 
Token | 
nextToken()
Return a token from this source; i.e., match a token on the char
  stream. 
 | 
void | 
notifyListeners(LexerNoViableAltException e)  | 
int | 
popMode()  | 
void | 
pushMode(int m)  | 
void | 
recover(LexerNoViableAltException e)  | 
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 | 
reset()  | 
void | 
setChannel(int channel)  | 
void | 
setCharPositionInLine(int charPositionInLine)  | 
void | 
setInputStream(IntStream input)
Set the char stream and reset the lexer 
 | 
void | 
setLine(int line)  | 
void | 
setText(String text)
Set the complete text of this token; it wipes any previous
  changes to the text. 
 | 
void | 
setToken(Token _token)  | 
void | 
setTokenFactory(TokenFactory<?> factory)
Optional method that lets users set factory in lexer or other source 
 | 
void | 
setType(int ttype)  | 
void | 
skip()
Instruct the lexer to skip creating a token for current lexer rule
  and look for another token. 
 | 
action, addErrorListener, getATN, getErrorHeader, getErrorListenerDispatch, getErrorListeners, getGrammarFileName, getInterpreter, getRuleNames, getState, getTokenErrorDisplay, removeErrorListener, removeErrorListeners, sempred, setInterpreter, setStatepublic static final int DEFAULT_MODE
public static final int MORE
public static final int SKIP
public static final int DEFAULT_TOKEN_CHANNEL
public static final int HIDDEN
public static final int MIN_CHAR_VALUE
public static final int MAX_CHAR_VALUE
public CharStream _input
protected Pair<TokenSource,CharStream> _tokenFactorySourcePair
protected TokenFactory<?> _factory
public Token _token
public int _tokenStartCharIndex
public int _tokenStartLine
public int _tokenStartCharPositionInLine
public boolean _hitEOF
public int _channel
public int _type
public final IntegerStack _modeStack
public int _mode
public String _text
public Lexer()
public Lexer(CharStream input)
public void reset()
public Token nextToken()
nextToken in interface TokenSourcepublic void skip()
public void more()
public void mode(int m)
public void pushMode(int m)
public int popMode()
public void setTokenFactory(TokenFactory<?> factory)
TokenSourcesetTokenFactory in interface TokenSourcesetTokenFactory in class Recognizer<Integer,LexerATNSimulator>public TokenFactory<? extends Token> getTokenFactory()
TokenSourcegetTokenFactory in interface TokenSourcegetTokenFactory in class Recognizer<Integer,LexerATNSimulator>public void setInputStream(IntStream input)
setInputStream in class Recognizer<Integer,LexerATNSimulator>public String getSourceName()
TokenSourcegetSourceName in interface TokenSourcepublic CharStream getInputStream()
TokenSourcegetInputStream in interface TokenSourcegetInputStream in class Recognizer<Integer,LexerATNSimulator>public void emit(Token token)
public Token emit()
public Token emitEOF()
public int getLine()
getLine in interface TokenSourcepublic int getCharPositionInLine()
getCharPositionInLine in interface TokenSourcepublic void setLine(int line)
public void setCharPositionInLine(int charPositionInLine)
public int getCharIndex()
public String getText()
public void setText(String text)
public Token getToken()
public void setToken(Token _token)
public void setType(int ttype)
public int getType()
public void setChannel(int channel)
public int getChannel()
public String[] getModeNames()
public String[] getTokenNames()
getTokenNames in class Recognizer<Integer,LexerATNSimulator>public List<? extends Token> getAllTokens()
public void recover(LexerNoViableAltException e)
public void notifyListeners(LexerNoViableAltException e)
public String getErrorDisplay(int c)
public String getCharErrorDisplay(int c)
public void recover(RecognitionException re)
Copyright © 1992-2013 ANTLR. All Rights Reserved.