Class SourceToken

java.lang.Object
net.emustudio.emulib.plugin.compiler.SourceToken
All Implemented Interfaces:
Token

public final class SourceToken extends Object implements Token
Immutable lexical token with an optional declaration name or include path.
  • Constructor Details

    • SourceToken

      public SourceToken(int type, int offset, String text)
    • SourceToken

      public SourceToken(int type, int offset, String text, String name, String referencedFile)
  • Method Details

    • getType

      public int getType()
      Description copied from interface: Token
      Get token type.

      The token type mus be one of the pre-defined constants located inside this interface (e.g. RESERVED, PREPROCESSOR, etc.).

      Specified by:
      getType in interface Token
      Returns:
      type of the token
    • getOffset

      public int getOffset()
      Description copied from interface: Token
      Get 0-based starting offset in UTF-16 code units (Java String indices).
      Specified by:
      getOffset in interface Token
      Returns:
      starting offset of the token in the source code
    • getText

      public String getText()
      Description copied from interface: Token
      Get token value.
      Specified by:
      getText in interface Token
      Returns:
      token value
    • getSymbolName

      public String getSymbolName()
      Description copied from interface: Token
      Symbol spelling, excluding punctuation, or null when this token has no symbol metadata.
      Specified by:
      getSymbolName in interface Token
    • getReferencedFile

      public String getReferencedFile()
      Description copied from interface: Token
      Referenced source file path, or null when the token is not an include path.
      Specified by:
      getReferencedFile in interface Token