AstNode lineAst = null;
try {
lineAst = pplineParser.parse(token.getValue()).getFirstChild();
} catch (com.sonar.sslr.api.RecognitionException re) {
LOG.warn("Cannot parse '{}', ignoring...", token.getValue());
return new PreprocessorAction(1, Lists.newArrayList(Trivia.createSkippedText(token)), new ArrayList<Token>());
}
String lineKind = lineAst.getName();
if ("ifdefLine".equals(lineKind)) {
return handleIfdefLine(lineAst, token, filePath);
} else if ("elseLine".equals(lineKind)) {
return handleElseLine(lineAst, token, filePath);
} else if ("endifLine".equals(lineKind)) {
return handleEndifLine(lineAst, token, filePath);
} else if ("ifLine".equals(lineKind)) {
return handleIfLine(lineAst, token, filePath);
} else if ("elifLine".equals(lineKind)) {
return handleElIfLine(lineAst, token, filePath);
}
if (inSkippingMode()) {
return new PreprocessorAction(1, Lists.newArrayList(Trivia.createSkippedText(token)), new ArrayList<Token>());
}
if ("defineLine".equals(lineKind)) {
return handleDefineLine(lineAst, token, filePath);
} else if ("includeLine".equals(lineKind)) {
return handleIncludeLine(lineAst, token, filePath);
} else if ("undefLine".equals(lineKind)) {
return handleUndefLine(lineAst, token, filePath);
}
// Ignore all other preprocessor directives (which are not handled explicitly)
// and strip them from the stream
return new PreprocessorAction(1, Lists.newArrayList(Trivia.createSkippedText(token)), new ArrayList<Token>());
}
if (ttype != EOF) {
if (inSkippingMode()) {
return new PreprocessorAction(1, Lists.newArrayList(Trivia.createSkippedText(token)), new ArrayList<Token>());
}
if (ttype != STRING && ttype != NUMBER) {
return handleIdentifiersAndKeywords(tokens, token, filePath);
}