Class TokenTagToken
- java.lang.Object
-
- org.antlr.v4.runtime.CommonToken
-
- org.antlr.v4.runtime.tree.pattern.TokenTagToken
-
- All Implemented Interfaces:
Serializable
,Token
,WritableToken
public class TokenTagToken extends CommonToken
AToken
object representing a token of a particular type; e.g.,<ID>
. These tokens are created forTagChunk
chunks where the tag corresponds to a lexer rule or token type.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.antlr.v4.runtime.CommonToken
channel, charPositionInLine, EMPTY_SOURCE, index, line, source, start, stop, text, type
-
Fields inherited from interface org.antlr.v4.runtime.Token
DEFAULT_CHANNEL, EOF, EPSILON, HIDDEN_CHANNEL, INVALID_TYPE, MIN_USER_CHANNEL_VALUE, MIN_USER_TOKEN_TYPE
-
-
Constructor Summary
Constructors Constructor Description TokenTagToken(String tokenName, int type)
Constructs a new instance ofTokenTagToken
for an unlabeled tag with the specified token name and type.TokenTagToken(String tokenName, int type, String label)
Constructs a new instance ofTokenTagToken
with the specified token name, type, and label.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getLabel()
Gets the label associated with the rule tag.String
getText()
Get the text of the token.String
getTokenName()
Gets the token name.String
toString()
-
Methods inherited from class org.antlr.v4.runtime.CommonToken
getChannel, getCharPositionInLine, getInputStream, getLine, getStartIndex, getStopIndex, getTokenIndex, getTokenSource, getType, setChannel, setCharPositionInLine, setLine, setStartIndex, setStopIndex, setText, setTokenIndex, setType, toString
-
-
-
-
Constructor Detail
-
TokenTagToken
public TokenTagToken(String tokenName, int type)
Constructs a new instance ofTokenTagToken
for an unlabeled tag with the specified token name and type.- Parameters:
tokenName
- The token name.type
- The token type.
-
TokenTagToken
public TokenTagToken(String tokenName, int type, String label)
Constructs a new instance ofTokenTagToken
with the specified token name, type, and label.- Parameters:
tokenName
- The token name.type
- The token type.label
- The label associated with the token tag, ornull
if the token tag is unlabeled.
-
-
Method Detail
-
getTokenName
public final String getTokenName()
Gets the token name.- Returns:
- The token name.
-
getLabel
public final String getLabel()
Gets the label associated with the rule tag.- Returns:
- The name of the label associated with the rule tag, or
null
if this is an unlabeled rule tag.
-
getText
public String getText()
Get the text of the token.The implementation for
TokenTagToken
returns the token tag formatted with<
and>
delimiters.- Specified by:
getText
in interfaceToken
- Overrides:
getText
in classCommonToken
-
toString
public String toString()
The implementation for
TokenTagToken
returns a string of the formtokenName:type
.- Overrides:
toString
in classCommonToken
-
-