Skip to content

Commit

Permalink
Merge pull request #846 from Bertk/fix-logs
Browse files Browse the repository at this point in the history
log only errors for parameter matching
  • Loading branch information
guwirth committed Apr 30, 2016
2 parents 3a124ad + 1303b20 commit 15f4caa
Showing 1 changed file with 19 additions and 13 deletions.
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

0 comments on commit 15f4caa

Please sign in to comment.