look for T not just TLexer if no parser just tokens.

This commit is contained in:
Terence Parr 2012-06-07 18:27:42 -07:00
parent b255509e96
commit 018e3c03e8
1 changed files with 11 additions and 2 deletions

View File

@ -127,7 +127,15 @@ public class TestRig {
// System.out.println("exec "+grammarName+"."+startRuleName);
String lexerName = grammarName+"Lexer";
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Class lexerClass = cl.loadClass(lexerName);
Class lexerClass = null;
try {
lexerClass = cl.loadClass(lexerName);
}
catch (java.lang.ClassNotFoundException cnfe) {
// might be pure lexer grammar; no Lexer suffix then
lexerName = grammarName;
lexerClass = cl.loadClass(lexerName);
}
if ( lexerClass==null ) {
System.err.println("Can't load "+lexerName);
}
@ -151,8 +159,9 @@ public class TestRig {
Lexer lexer = lexerCtor.newInstance(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
tokens.fill();
if ( showTokens ) {
tokens.fill();
for (Object tok : tokens.getTokens()) {
System.out.println(tok);
}