Module hw06

Class TokenFactory

java.lang.Object
provided.tokenFW.TokenFactory
All Implemented Interfaces:
ITokenFactory

public class TokenFactory extends Object implements ITokenFactory
Concrete factory to create tokens
  • Field Details

    • Singleton

      public static final TokenFactory Singleton
      Singleton instance of this class
  • Constructor Details

    • TokenFactory

      private TokenFactory()
      private constructor needed for singleton
  • Method Details

    • makeToken

      public Token makeToken(String name, String lexeme)
      Creates Tokens from the given name and lexeme. The returned tokens will call the case in their visitors corresponding to their *name*. For many tokens the name and lexeme are the same, but for some, it is not, e.g. an Quote token, where the name is "Quote", but the lexeme is the string value of the quoted text.
      Specified by:
      makeToken in interface ITokenFactory
      Parameters:
      name - The name of the token
      lexeme - The lexeme value for the token
      Returns:
      An Token instance with the given name and lexeme which calls the named case of its visitors.