forked from jasder/antlr
small improvement in error msg
This commit is contained in:
parent
78c75ee5e4
commit
e366f00820
|
@ -138,19 +138,21 @@ public class TestRig {
|
||||||
// System.out.println("exec "+grammarName+"."+startRuleName);
|
// System.out.println("exec "+grammarName+"."+startRuleName);
|
||||||
String lexerName = grammarName+"Lexer";
|
String lexerName = grammarName+"Lexer";
|
||||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||||
Class<? extends Lexer> lexerClass;
|
Class<? extends Lexer> lexerClass = null;
|
||||||
try {
|
try {
|
||||||
lexerClass = cl.loadClass(lexerName).asSubclass(Lexer.class);
|
lexerClass = cl.loadClass(lexerName).asSubclass(Lexer.class);
|
||||||
}
|
}
|
||||||
catch (java.lang.ClassNotFoundException cnfe) {
|
catch (java.lang.ClassNotFoundException cnfe) {
|
||||||
// might be pure lexer grammar; no Lexer suffix then
|
// might be pure lexer grammar; no Lexer suffix then
|
||||||
lexerName = grammarName;
|
lexerName = grammarName;
|
||||||
|
try {
|
||||||
lexerClass = cl.loadClass(lexerName).asSubclass(Lexer.class);
|
lexerClass = cl.loadClass(lexerName).asSubclass(Lexer.class);
|
||||||
}
|
}
|
||||||
if ( lexerClass==null ) {
|
catch (ClassNotFoundException cnfe2) {
|
||||||
System.err.println("Can't load "+lexerName);
|
System.err.println("Can't load "+lexerName+" as lexer or parser");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Constructor<? extends Lexer> lexerCtor = lexerClass.getConstructor(CharStream.class);
|
Constructor<? extends Lexer> lexerCtor = lexerClass.getConstructor(CharStream.class);
|
||||||
Lexer lexer = lexerCtor.newInstance((CharStream)null);
|
Lexer lexer = lexerCtor.newInstance((CharStream)null);
|
||||||
|
|
Loading…
Reference in New Issue