Class TokenTagToken

  • All Implemented Interfaces:
    java.io.Serializable, Token, WritableToken

    public class TokenTagToken
    extends CommonToken
    A Token object representing a token of a particular type; e.g., <ID>. These tokens are created for TagChunk chunks where the tag corresponds to a lexer rule or token type.
    See Also:
    Serialized Form
    • Constructor Detail

      • TokenTagToken

        public TokenTagToken​(java.lang.String tokenName,
                             int type)
        Constructs a new instance of TokenTagToken for an unlabeled tag with the specified token name and type.
        Parameters:
        tokenName - The token name.
        type - The token type.
      • TokenTagToken

        public TokenTagToken​(java.lang.String tokenName,
                             int type,
                             java.lang.String label)
        Constructs a new instance of TokenTagToken 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, or null if the token tag is unlabeled.
    • Method Detail

      • getTokenName

        public final java.lang.String getTokenName()
        Gets the token name.
        Returns:
        The token name.
      • getLabel

        public final java.lang.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 java.lang.String getText()
        Get the text of the token.

        The implementation for TokenTagToken returns the token tag formatted with < and > delimiters.

        Specified by:
        getText in interface Token
        Overrides:
        getText in class CommonToken
      • toString

        public java.lang.String toString()

        The implementation for TokenTagToken returns a string of the form tokenName:type.

        Overrides:
        toString in class CommonToken