forked from jasder/antlr
Extract abstract method in Recognizer for Parser.getGrammarFileName() and generated lexer's getGrammarFileName(). Make Recognizer.getTokenNames(), getRuleNames(), and getATN() abstract - implementations are always generated.
This commit is contained in:
parent
d166e6d5d1
commit
a81b1a17eb
|
@ -476,13 +476,6 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator<Token>
|
|||
return stack;
|
||||
}
|
||||
|
||||
/** For debugging and other purposes, might want the grammar name.
|
||||
* Have ANTLR generate an implementation for this method.
|
||||
*/
|
||||
public String getGrammarFileName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** For debugging and other purposes */
|
||||
public List<String> getDFAStrings() {
|
||||
List<String> s = new ArrayList<String>();
|
||||
|
|
|
@ -53,15 +53,16 @@ public abstract class Recognizer<Symbol, ATNInterpreter extends ATNSimulator> {
|
|||
* error reporting. The generated parsers implement a method
|
||||
* that overrides this to point to their String[] tokenNames.
|
||||
*/
|
||||
public String[] getTokenNames() {
|
||||
return null;
|
||||
}
|
||||
public abstract String[] getTokenNames();
|
||||
|
||||
public String[] getRuleNames() {
|
||||
return null;
|
||||
}
|
||||
public abstract String[] getRuleNames();
|
||||
|
||||
public ATN getATN() { return null; }
|
||||
/** For debugging and other purposes, might want the grammar name.
|
||||
* Have ANTLR generate an implementation for this method.
|
||||
*/
|
||||
public abstract String getGrammarFileName();
|
||||
|
||||
public abstract ATN getATN();
|
||||
|
||||
public ATNInterpreter getInterpreter() { return _interp; }
|
||||
|
||||
|
|
|
@ -723,6 +723,7 @@ public class <lexer.name> extends Lexer {
|
|||
_interp = new LexerATNSimulator(this,_ATN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGrammarFileName() { return "<lexer.grammarFileName>"; }
|
||||
|
||||
@Override
|
||||
|
|
|
@ -45,6 +45,11 @@ public class ParserInterpreter {
|
|||
this.g = g;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGrammarFileName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getRuleNames() {
|
||||
return g.rules.keySet().toArray(new String[g.rules.size()]);
|
||||
|
@ -54,6 +59,11 @@ public class ParserInterpreter {
|
|||
public String[] getTokenNames() {
|
||||
return g.getTokenNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ATN getATN() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected Grammar g;
|
||||
|
|
Loading…
Reference in New Issue