antlr
Class SimpleTokenManager

java.lang.Object
  |
  +--antlr.SimpleTokenManager
All Implemented Interfaces:
java.lang.Cloneable, TokenManager
Direct Known Subclasses:
ImportVocabTokenManager

class SimpleTokenManager
extends java.lang.Object
implements TokenManager, java.lang.Cloneable


Field Summary
protected  int maxToken
           
protected  java.lang.String name
           
protected  boolean readOnly
           
private  java.util.Hashtable table
           
protected  Tool tool
           
protected  Vector vocabulary
           
 
Constructor Summary
(package private) SimpleTokenManager(java.lang.String name_, Tool tool_)
           
 
Method Summary
 java.lang.Object clone()
           
 void define(TokenSymbol ts)
          define a token
 java.lang.String getName()
          Simple token manager doesn't have a name -- must be set externally
 java.lang.String getTokenStringAt(int idx)
          Get a token symbol by index
 TokenSymbol getTokenSymbol(java.lang.String sym)
          Get the TokenSymbol for a string
 TokenSymbol getTokenSymbolAt(int idx)
          Get a token symbol by index
 java.util.Enumeration getTokenSymbolElements()
          Get an enumerator over the symbol table
 java.util.Enumeration getTokenSymbolKeys()
           
 Vector getVocabulary()
          Get the token vocabulary (read-only).
 boolean isReadOnly()
          Simple token manager is not read-only
 void mapToTokenSymbol(java.lang.String name, TokenSymbol sym)
          Map a label or string to an existing token symbol
 int maxTokenType()
          Get the highest token type in use
 int nextTokenType()
          Get the next unused token type
 void setName(java.lang.String name_)
          Set the name of the token manager
 void setReadOnly(boolean ro)
           
 boolean tokenDefined(java.lang.String symbol)
          Is a token symbol defined?
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxToken

protected int maxToken

vocabulary

protected Vector vocabulary

table

private java.util.Hashtable table

tool

protected Tool tool

name

protected java.lang.String name

readOnly

protected boolean readOnly
Constructor Detail

SimpleTokenManager

SimpleTokenManager(java.lang.String name_,
                   Tool tool_)
Method Detail

clone

public java.lang.Object clone()
Specified by:
clone in interface TokenManager
Overrides:
clone in class java.lang.Object

define

public void define(TokenSymbol ts)
define a token

Specified by:
define in interface TokenManager

getName

public java.lang.String getName()
Simple token manager doesn't have a name -- must be set externally

Specified by:
getName in interface TokenManager

getTokenStringAt

public java.lang.String getTokenStringAt(int idx)
Get a token symbol by index

Specified by:
getTokenStringAt in interface TokenManager

getTokenSymbol

public TokenSymbol getTokenSymbol(java.lang.String sym)
Get the TokenSymbol for a string

Specified by:
getTokenSymbol in interface TokenManager

getTokenSymbolAt

public TokenSymbol getTokenSymbolAt(int idx)
Get a token symbol by index

Specified by:
getTokenSymbolAt in interface TokenManager

getTokenSymbolElements

public java.util.Enumeration getTokenSymbolElements()
Get an enumerator over the symbol table

Specified by:
getTokenSymbolElements in interface TokenManager

getTokenSymbolKeys

public java.util.Enumeration getTokenSymbolKeys()
Specified by:
getTokenSymbolKeys in interface TokenManager

getVocabulary

public Vector getVocabulary()
Get the token vocabulary (read-only).

Specified by:
getVocabulary in interface TokenManager
Returns:
A Vector of TokenSymbol

isReadOnly

public boolean isReadOnly()
Simple token manager is not read-only

Specified by:
isReadOnly in interface TokenManager

mapToTokenSymbol

public void mapToTokenSymbol(java.lang.String name,
                             TokenSymbol sym)
Map a label or string to an existing token symbol

Specified by:
mapToTokenSymbol in interface TokenManager

maxTokenType

public int maxTokenType()
Get the highest token type in use

Specified by:
maxTokenType in interface TokenManager

nextTokenType

public int nextTokenType()
Get the next unused token type

Specified by:
nextTokenType in interface TokenManager

setName

public void setName(java.lang.String name_)
Set the name of the token manager

Specified by:
setName in interface TokenManager

setReadOnly

public void setReadOnly(boolean ro)
Specified by:
setReadOnly in interface TokenManager

tokenDefined

public boolean tokenDefined(java.lang.String symbol)
Is a token symbol defined?

Specified by:
tokenDefined in interface TokenManager