Class Token


  • public final class Token
    extends java.lang.Object
    The Token class is used to store information about characters in the form of a Token.

    It takes the type, syntax, value, and position of a piece of text, and is then used to represent that text from that point on.

    Since:
    1.0
    • Constructor Summary

      Constructors 
      Constructor Description
      Token​(TokenType type, java.lang.String syntax, int position)
      Constructs a Token object initialised with information about a piece of text, but without a value.
      Token​(TokenType type, java.lang.String syntax, java.lang.Object value, int position)
      Constructs a Token object initialised with information about a piece of text.
    • Method Summary

      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Token

        public Token​(TokenType type,
                     java.lang.String syntax,
                     java.lang.Object value,
                     int position)
        Constructs a Token object initialised with information about a piece of text.

        A SourceSpan object is automatically generated based on the position and length of the syntax.

        Parameters:
        type - The TokenType of the text
        syntax - The text itself
        value - The value of the text
        position - The position of the text relative to the String it originates from
      • Token

        public Token​(TokenType type,
                     java.lang.String syntax,
                     int position)
        Constructs a Token object initialised with information about a piece of text, but without a value.

        A SourceSpan object is automatically generated based on the position and length of the syntax. The Tokens 'value' field is set to null.

        Parameters:
        type - The TokenType of the text
        syntax - The text itself
        position - The position of the text relative to the String it originates from