Methods Summary |
---|
public void | define(persistence.antlr.RuleSymbol rs)Define a rule
rules.appendElement(rs);
// add the symbol to the rules hash table
symbols.put(rs.getId(), rs);
|
public abstract void | generate()Top-level call to generate the code for this grammar
|
protected java.lang.String | getClassName()
return className;
|
public boolean | getDefaultErrorHandler()
return defaultErrorHandler;
|
public java.lang.String | getFilename()
return fileName;
|
public int | getIntegerOption(java.lang.String key)Get an integer option. Given the name of the option find its
associated integer value. If the associated value is not an integer or
is not in the table, then throw an exception of type NumberFormatException.
Token t = (Token)options.get(key);
if (t == null || t.getType() != ANTLRTokenTypes.INT) {
throw new NumberFormatException();
}
else {
return Integer.parseInt(t.getText());
}
|
public persistence.antlr.Token | getOption(java.lang.String key)Get an option. Given the name of the option find its associated value.
return (Token)options.get(key);
|
protected abstract java.lang.String | getSuperClass()
|
public persistence.antlr.GrammarSymbol | getSymbol(java.lang.String s)
return (GrammarSymbol)symbols.get(s);
|
public java.util.Enumeration | getSymbols()
return symbols.elements();
|
public boolean | hasOption(java.lang.String key)Check the existence of an option in the table
return options.containsKey(key);
|
public boolean | isDefined(java.lang.String s)Is a rule symbol defined? (not used for tokens)
return symbols.containsKey(s);
|
public abstract void | processArguments(java.lang.String[] args)Process command line arguments. Implemented in subclasses
|
public void | setCodeGenerator(persistence.antlr.CodeGenerator gen)
generator = gen;
|
public void | setFilename(java.lang.String s)
fileName = s;
|
public void | setGrammarAnalyzer(persistence.antlr.LLkGrammarAnalyzer a)
theLLkAnalyzer = a;
|
public boolean | setOption(java.lang.String key, persistence.antlr.Token value)Set a generic option.
This associates a generic option key with a Token value.
No validation is performed by this method, although users of the value
(code generation and/or analysis) may require certain formats.
The value is stored as a token so that the location of an error
can be reported.
options.put(key, value);
String s = value.getText();
int i;
if (key.equals("k")) {
try {
maxk = getIntegerOption("k");
if ( maxk<=0 ) {
antlrTool.error("option 'k' must be greater than 0 (was " +
value.getText() + ")",
getFilename(),
value.getLine(),
value.getColumn());
maxk = 1;
}
}
catch (NumberFormatException e) {
antlrTool.error("option 'k' must be an integer (was " + value.getText() + ")", getFilename(), value.getLine(), value.getColumn());
}
return true;
}
if (key.equals("codeGenMakeSwitchThreshold")) {
try {
i = getIntegerOption("codeGenMakeSwitchThreshold");
}
catch (NumberFormatException e) {
antlrTool.error("option 'codeGenMakeSwitchThreshold' must be an integer", getFilename(), value.getLine(), value.getColumn());
}
return true;
}
if (key.equals("codeGenBitsetTestThreshold")) {
try {
i = getIntegerOption("codeGenBitsetTestThreshold");
}
catch (NumberFormatException e) {
antlrTool.error("option 'codeGenBitsetTestThreshold' must be an integer", getFilename(), value.getLine(), value.getColumn());
}
return true;
}
if (key.equals("defaultErrorHandler")) {
if (s.equals("true")) {
defaultErrorHandler = true;
}
else if (s.equals("false")) {
defaultErrorHandler = false;
}
else {
antlrTool.error("Value for defaultErrorHandler must be true or false", getFilename(), value.getLine(), value.getColumn());
}
return true;
}
if (key.equals("analyzerDebug")) {
if (s.equals("true")) {
analyzerDebug = true;
}
else if (s.equals("false")) {
analyzerDebug = false;
}
else {
antlrTool.error("option 'analyzerDebug' must be true or false", getFilename(), value.getLine(), value.getColumn());
}
return true;
}
if (key.equals("codeGenDebug")) {
if (s.equals("true")) {
analyzerDebug = true;
}
else if (s.equals("false")) {
analyzerDebug = false;
}
else {
antlrTool.error("option 'codeGenDebug' must be true or false", getFilename(), value.getLine(), value.getColumn());
}
return true;
}
if (key.equals("classHeaderSuffix")) {
return true;
}
if (key.equals("classHeaderPrefix")) {
return true;
}
if (key.equals("namespaceAntlr")) {
return true;
}
if (key.equals("namespaceStd")) {
return true;
}
if (key.equals("genHashLines")) {
return true;
}
if (key.equals("noConstructors")) {
return true;
}
return false;
|
public void | setTokenManager(persistence.antlr.TokenManager tokenManager_)
tokenManager = tokenManager_;
|
public java.lang.String | toString()Print out the grammar without actions
StringBuffer buf = new StringBuffer(20000);
Enumeration ids = rules.elements();
while (ids.hasMoreElements()) {
RuleSymbol rs = (RuleSymbol)ids.nextElement();
if (!rs.id.equals("mnextToken")) {
buf.append(rs.getBlock().toString());
buf.append("\n\n");
}
}
return buf.toString();
|