antlr
Class ImportVocabTokenManager

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

class ImportVocabTokenManager
extends SimpleTokenManager
implements java.lang.Cloneable

Static implementation of the TokenManager, used for importVocab option


Field Summary
private  java.lang.String filename
           
protected  Grammar grammar
           
protected  int maxToken
           
protected  java.lang.String name
           
protected  boolean readOnly
           
protected  Tool tool
           
protected  Vector vocabulary
           
 
Constructor Summary
(package private) ImportVocabTokenManager(Grammar grammar, java.lang.String filename_, java.lang.String name_, Tool tool_)
           
 
Method Summary
 java.lang.Object clone()
           
 void define(java.lang.String s, int ttype)
          define a token.
 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()
          importVocab token manager is read-only if output would be same as input
 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

filename

private java.lang.String filename

grammar

protected Grammar grammar

maxToken

protected int maxToken

vocabulary

protected Vector vocabulary

tool

protected Tool tool

name

protected java.lang.String name

readOnly

protected boolean readOnly
Constructor Detail

ImportVocabTokenManager

ImportVocabTokenManager(Grammar grammar,
                        java.lang.String filename_,
                        java.lang.String name_,
                        Tool tool_)
Method Detail

clone

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

define

public void define(TokenSymbol ts)
define a token.

Specified by:
define in interface TokenManager
Overrides:
define in class SimpleTokenManager

define

public void define(java.lang.String s,
                   int ttype)
define a token. Intended for use only when reading the importVocab file.


isReadOnly

public boolean isReadOnly()
importVocab token manager is read-only if output would be same as input

Specified by:
isReadOnly in interface TokenManager
Overrides:
isReadOnly in class SimpleTokenManager

nextTokenType

public int nextTokenType()
Get the next unused token type.

Specified by:
nextTokenType in interface TokenManager
Overrides:
nextTokenType in class SimpleTokenManager

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

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

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