antlr

Class SimpleTokenManager

Implemented Interfaces:
Cloneable, TokenManager
Known Direct Subclasses:
ImportVocabTokenManager

(package private) class SimpleTokenManager
extends Object
implements TokenManager, Cloneable

Field Summary

protected Tool
antlrTool
protected int
maxToken
protected String
name
protected boolean
readOnly
protected Vector
vocabulary

Constructor Summary

SimpleTokenManager(String name_, Tool tool_)

Method Summary

Object
clone()
void
define(TokenSymbol ts)
define a token
String
getName()
Simple token manager doesn't have a name -- must be set externally
String
getTokenStringAt(int idx)
Get a token symbol by index
TokenSymbol
getTokenSymbol(String sym)
Get the TokenSymbol for a string
TokenSymbol
getTokenSymbolAt(int idx)
Get a token symbol by index
Enumeration
getTokenSymbolElements()
Get an enumerator over the symbol table
Enumeration
getTokenSymbolKeys()
Vector
getVocabulary()
Get the token vocabulary (read-only).
boolean
isReadOnly()
Simple token manager is not read-only
void
mapToTokenSymbol(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(String name_)
Set the name of the token manager
void
setReadOnly(boolean ro)
boolean
tokenDefined(String symbol)
Is a token symbol defined?

Field Details

antlrTool

protected Tool antlrTool


maxToken

protected int maxToken


name

protected String name


readOnly

protected boolean readOnly


vocabulary

protected Vector vocabulary

Constructor Details

SimpleTokenManager

(package private)  SimpleTokenManager(String name_,
                                      Tool tool_)

Method Details

clone

public Object clone()
Specified by:
clone in interface TokenManager


define

public void define(TokenSymbol ts)
define a token
Specified by:
define in interface TokenManager


getName

public String getName()
Simple token manager doesn't have a name -- must be set externally
Specified by:
getName in interface TokenManager


getTokenStringAt

public String getTokenStringAt(int idx)
Get a token symbol by index
Specified by:
getTokenStringAt in interface TokenManager


getTokenSymbol

public TokenSymbol getTokenSymbol(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 Enumeration getTokenSymbolElements()
Get an enumerator over the symbol table
Specified by:
getTokenSymbolElements in interface TokenManager


getTokenSymbolKeys

public 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(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(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(String symbol)
Is a token symbol defined?
Specified by:
tokenDefined in interface TokenManager