List<LexerToken> resultTokenList = new ArrayList<LexerToken>();
int outputLine = 1;
try {
// TokenFilter tokenFilter = new TokenFilter();
for (; ; ) {
LexerToken tok = pp.getNextToken();
if (tok == null)
break;
if (tok.isEOF())
break;
if (returnTokenList && (!options.isReturnLanguageTokensOnly() || tok.isLanguageToken())) {
resultTokenList.add(tok);
}
if (output != null) {
if (options.isAdjustLineNumbers()) {
//adjust line numbers to .pi file for debugging
String image = tok.getText();
while (image.indexOf('\n') >= 0) {
outputLine++;
image = image.substring(image.indexOf('\n') + 1);
}
tok.setLine(outputLine);
if (options.getLexOutputFile() != null)
tok.setSourceName(options.getLexOutputFile());
}
//write to .pi file
tok.lazyPrint(output);
}
}
} catch (Throwable e) {
Preprocessor.logger.severe(e.toString());
e.printStackTrace(System.err);