Package eu.bandm.tools.xantlr.runtime
Class HistoryToken
java.lang.Object
antlr.Token
antlr.CommonToken
antlr.CommonHiddenStreamToken
eu.bandm.tools.xantlr.runtime.HistoryToken
- All Implemented Interfaces:
Cloneable
public class HistoryToken
extends antlr.CommonHiddenStreamToken
A runtime class for
xantlr. generated lexers and parsers,
which carries over information from the last consumed token.
A Lexer generated by xantlr provides the END point of each recognized token. In the context of event generation as done by any xantlr generated parsers, location information has to be constructed, which needs the end position of the last, not the current, token. To provide an access to this data, the objects of this class are tokens which duplicate some positional information of their predecessor in the token stream.
E.g., whenever a
Attention : Whenever applying a Filter to a token stream of HistoryTokens, it must be derived from
A Lexer generated by xantlr provides the END point of each recognized token. In the context of event generation as done by any xantlr generated parsers, location information has to be constructed, which needs the end position of the last, not the current, token. To provide an access to this data, the objects of this class are tokens which duplicate some positional information of their predecessor in the token stream.
E.g., whenever a
X_LLkParser
is used, it has to be linked to a lexer
by new MyParser(HistoryToken.chain(MyLexer))
.
Attention : Whenever applying a Filter to a token stream of HistoryTokens, it must be derived from
HistoryTokenFilter
, for
additionally copying this information across the tokens discarded.-
Field Summary
Fields inherited from class antlr.CommonHiddenStreamToken
hiddenAfter, hiddenBefore
Fields inherited from class antlr.CommonToken
col, line, text
Fields inherited from class antlr.Token
badToken, EOF_TYPE, INVALID_TYPE, MIN_USER_TYPE, NULL_TREE_LOOKAHEAD, SKIP
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic antlr.TokenStream
chain
(antlr.CharScanner in) final int
final String
final int
void
setFilename
(String filename) void
setLastToken
(int line, int column) void
setLastToken
(String filename, int line, int column) Methods inherited from class antlr.CommonHiddenStreamToken
getHiddenAfter, getHiddenBefore, setHiddenAfter, setHiddenBefore
Methods inherited from class antlr.CommonToken
getColumn, getLine, getText, setColumn, setLine, setText, toString
Methods inherited from class antlr.Token
getType, setType
-
Constructor Details
-
HistoryToken
public HistoryToken() -
HistoryToken
-
-
Method Details
-
setFilename
- Overrides:
setFilename
in classantlr.Token
-
getFilename
- Overrides:
getFilename
in classantlr.Token
-
setLastToken
public void setLastToken(int line, int column) -
setLastToken
-
getLastTokenFilename
-
getLastTokenLine
public final int getLastTokenLine() -
getLastTokenColumn
public final int getLastTokenColumn() -
chain
public static antlr.TokenStream chain(antlr.CharScanner in)
-