Methods Summary |
---|
public java.lang.Object | clone()
SimpleTokenManager tm;
try {
tm = (SimpleTokenManager)super.clone();
tm.vocabulary = (Vector)this.vocabulary.clone();
tm.table = (Hashtable)this.table.clone();
tm.maxToken = this.maxToken;
tm.antlrTool = this.antlrTool;
tm.name = this.name;
}
catch (CloneNotSupportedException e) {
antlrTool.panic("cannot clone token manager");
return null;
}
return tm;
|
public void | define(persistence.antlr.TokenSymbol ts)define a token
// Add the symbol to the vocabulary vector
vocabulary.ensureCapacity(ts.getTokenType());
vocabulary.setElementAt(ts.getId(), ts.getTokenType());
// add the symbol to the hash table
mapToTokenSymbol(ts.getId(), ts);
|
public java.lang.String | getName()Simple token manager doesn't have a name -- must be set externally
return name;
|
public java.lang.String | getTokenStringAt(int idx)Get a token symbol by index
return (String)vocabulary.elementAt(idx);
|
public persistence.antlr.TokenSymbol | getTokenSymbol(java.lang.String sym)Get the TokenSymbol for a string
return (TokenSymbol)table.get(sym);
|
public persistence.antlr.TokenSymbol | getTokenSymbolAt(int idx)Get a token symbol by index
return getTokenSymbol(getTokenStringAt(idx));
|
public java.util.Enumeration | getTokenSymbolElements()Get an enumerator over the symbol table
return table.elements();
|
public java.util.Enumeration | getTokenSymbolKeys()
return table.keys();
|
public persistence.antlr.collections.impl.Vector | getVocabulary()Get the token vocabulary (read-only).
return vocabulary;
|
public boolean | isReadOnly()Simple token manager is not read-only
return false;
|
public void | mapToTokenSymbol(java.lang.String name, persistence.antlr.TokenSymbol sym)Map a label or string to an existing token symbol
// System.out.println("mapToTokenSymbol("+name+","+sym+")");
table.put(name, sym);
|
public int | maxTokenType()Get the highest token type in use
return maxToken - 1;
|
public int | nextTokenType()Get the next unused token type
return maxToken++;
|
public void | setName(java.lang.String name_)Set the name of the token manager
name = name_;
|
public void | setReadOnly(boolean ro)
readOnly = ro;
|
public boolean | tokenDefined(java.lang.String symbol)Is a token symbol defined?
return table.containsKey(symbol);
|