combinedGrammarFileName = grammarFileName;
break;
}
ANTLRInputStream input = new ANTLRInputStream(inputText);
LexerInterpreter lexEngine;
if (combinedGrammarFileName != null) {
lexEngine = g.createLexerInterpreter(input);
}
else {
LexerGrammar lg = null;
try {
lg = (LexerGrammar) Grammar.load(lexerGrammarFileName);
} catch (ClassCastException cce) {
out.println("File " + lexerGrammarFileName + " isn't a lexer grammar");
}
g = loadGrammar(antlr, parserGrammarFileName, lg);
lexEngine = lg.createLexerInterpreter(input);
}
final String gname = g.name;
BaseErrorListener printError = new BaseErrorListener() {
@Override
public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol,
final int line, final int position, final String msg,
final RecognitionException e) {
out.println(gname + "::" + startRule + ":" + line + ":" + position + ": " + msg);
}
};
lexEngine.removeErrorListeners();
lexEngine.addErrorListener(printError);
CommonTokenStream tokens = new CommonTokenStream(lexEngine);
ParserInterpreter parser = g.createParserInterpreter(tokens);
parser.removeErrorListeners();