Class Ek9Token

java.lang.Object
org.ek9lang.compiler.tokenizer.Ek9Token
All Implemented Interfaces:
Serializable, IToken

public class Ek9Token extends Object implements IToken
Models a token that we need to create as a synthetic token. The EK9 compiler sometimes needs to deal with tokens that were not in the actual source code input.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new token with default name of 'Synthetic'.
    Ek9Token(int type, String textName, int lineNumber, String sourceName, int charPositionInLine, int tokenIndex)
    Create a new token with all necessary details.
    Ek9Token(String textName)
    Create a new token with a specific name.
    Ek9Token(String textName, int lineNumber)
    Create a new token with name and specific line number.
    Ek9Token(String textName, int lineNumber, String sourceName)
    Create a new token with name, specific line number and named source file.
    Ek9Token(org.antlr.v4.runtime.Token token)
    Pull out all relevant details of an ANTLR Token into a minimal EK9Token.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    int
    The index of the first character of this token relative to the beginning of the line at which it occurs, 0..n-1
    int
    The line number on which the 1st character of this token was matched, line=1..n
    The name of the source (if known).
    The actual text of the token itself.
    int
    An index from 0..n-1 of the token object in the input stream.
    int
    The type of token.
    int
     
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Ek9Token

      public Ek9Token()
      Create a new token with default name of 'Synthetic'.
    • Ek9Token

      public Ek9Token(String textName)
      Create a new token with a specific name.
    • Ek9Token

      public Ek9Token(String textName, int lineNumber)
      Create a new token with name and specific line number.
    • Ek9Token

      public Ek9Token(String textName, int lineNumber, String sourceName)
      Create a new token with name, specific line number and named source file.
    • Ek9Token

      public Ek9Token(int type, String textName, int lineNumber, String sourceName, int charPositionInLine, int tokenIndex)
      Create a new token with all necessary details.
    • Ek9Token

      public Ek9Token(org.antlr.v4.runtime.Token token)
      Pull out all relevant details of an ANTLR Token into a minimal EK9Token.
  • Method Details

    • getType

      public int getType()
      Description copied from interface: IToken
      The type of token.
      Specified by:
      getType in interface IToken
    • getText

      public String getText()
      Description copied from interface: IToken
      The actual text of the token itself.
      Specified by:
      getText in interface IToken
    • getSourceName

      public String getSourceName()
      Description copied from interface: IToken
      The name of the source (if known).
      Specified by:
      getSourceName in interface IToken
    • getLine

      public int getLine()
      Description copied from interface: IToken
      The line number on which the 1st character of this token was matched, line=1..n
      Specified by:
      getLine in interface IToken
    • getCharPositionInLine

      public int getCharPositionInLine()
      Description copied from interface: IToken
      The index of the first character of this token relative to the beginning of the line at which it occurs, 0..n-1
      Specified by:
      getCharPositionInLine in interface IToken
    • getTokenIndex

      public int getTokenIndex()
      Description copied from interface: IToken
      An index from 0..n-1 of the token object in the input stream. This must be valid in order to print token streams and use TokenRewriteStream.
      Return -1 to indicate that this token was conjured up since it doesn't have a valid index.
      Specified by:
      getTokenIndex in interface IToken
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object