token
Class TokenFactory

java.lang.Object
  extended by token.TokenFactory
All Implemented Interfaces:
ITokenFactory

public class TokenFactory
extends java.lang.Object
implements ITokenFactory

Concrete factory to create tokens


Field Summary
static TokenFactory Singleton
           
 
Constructor Summary
private TokenFactory()
           
 
Method Summary
 Token makeToken(java.lang.String name, java.lang.String lexeme)
          Creates ATokens from the given name and lexeme.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Singleton

public static final TokenFactory Singleton
Constructor Detail

TokenFactory

private TokenFactory()
Method Detail

makeToken

public Token makeToken(java.lang.String name,
                       java.lang.String lexeme)
Creates ATokens from the given name and lexeme. The returned tokens will call the case in their visitors corresponding to their *name*. For most tokens the name and lexeme are the same, but for some, it is not, e.g. an Id token, where the name is "Id", but the lexeme is the string value or a number token where the name is "Num", but the lexeme is the string representation of the numerical value. The idea is for all Id tokens and number tokens to call be processed identically by having them call the same case on their visitors.

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.