Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log only errors for parameter matching #846

Merged
merged 2 commits into from
Apr 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,19 @@ public final void reset() {
}

static class MismatchException extends Exception {
private static final long serialVersionUID = 1960113363232807009L;

private final String why;

MismatchException(String why) {
this.why = why;
MismatchException(String message) {
super(message);
}

@Override
public String toString() {
return why;
MismatchException(Throwable cause) {
super(cause);
}
MismatchException(String message, Throwable cause) {
super(message, cause);
}
MismatchException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);;
}
}

Expand Down Expand Up @@ -252,7 +255,7 @@ public CxxPreprocessor(SquidAstVisitorContext<Grammar> context,
if (!"".equals(define)) {
Macro macro = parseMacroDefinition("#define " + define);
if (macro != null) {
LOG.info("storing external macro: '{}'", macro);
LOG.debug("storing external macro: '{}'", macro);
macros.put(macro.name, macro);
}
}
Expand Down Expand Up @@ -576,6 +579,9 @@ PreprocessorAction handleIncludeLine(AstNode ast, Token token, String filename)
currentFileState = globalStateStack.pop();
}
}
// else {
// LOG.debug("[{}:{}]: skipping already included file '{}'", new Object[] {filename, token.getLine(), includedFile});
// }

return new PreprocessorAction(1, Lists.newArrayList(Trivia.createSkippedText(token)), new ArrayList<Token>());
}
Expand Down Expand Up @@ -743,21 +749,21 @@ private int matchArguments(List<Token> tokens, List<Token> arguments) {
break;
}
} while (true);

} catch (MismatchException me) {}
try {
rest = match(rest, ")");
} catch (MismatchException me) {
LOG.error("MismatchException : '{}' rest: '{}'", me.getMessage(), rest);
return 0;
}

return tokens.size() - rest.size();
}

private List<Token> match(List<Token> tokens, String str) throws MismatchException {
if (!tokens.get(0).getValue().equals(str)) {
LOG.error("Mismatch: expected '" + str + "' got: '" + tokens.get(0).getValue() + "'");
throw new MismatchException("Mismatch: expected '" + str + "' got: '"
+ tokens.get(0).getValue() + "'");
+ tokens.get(0).getValue() + "'" + " [" + tokens.get(0).getURI() + "("
+ tokens.get(0).getLine() + "," + tokens.get(0).getColumn() + ")]");
}
return tokens.subList(1, tokens.size());
}
Expand Down