Package jminusminus

Class TokenInfo

java.lang.Object
jminusminus.TokenInfo

public class TokenInfo extends Object
A representation of tokens returned by the Scanner method getNextToken(). A token has a kind identifying what kind of token it is, an image for providing any semantic text, and the line in which it occurred in the source file.
  • Constructor Details

    • TokenInfo

      public TokenInfo(TokenKind kind, String image, int line)
      Constructs a TokenInfo object given its kind, the semantic text forming the token, and its line number.
      Parameters:
      kind - the token's kind.
      image - the semantic text forming the token.
      line - the line in which the token occurs in the source file.
    • TokenInfo

      public TokenInfo(TokenKind kind, int line)
      Constructs a TokenInfo object given its kind and its line number. Its image is simply the token kind's string representation.
      Parameters:
      kind - the token's identifying number.
      line - the line in which the token occurs in the source file.
  • Method Details

    • kind

      public TokenKind kind()
      Returns the token's kind.
      Returns:
      the token's kind.
    • line

      public int line()
      Returns the line number associated with the token.
      Returns:
      the line number associated with the token.
    • tokenRep

      public String tokenRep()
      Returns the token's string representation.
      Returns:
      the token's string representation.
    • image

      public String image()
      Returns the token's image.
      Returns:
      the token's image.