int offendingState = re.getOffendingState();
Integer offendingToken = null;
if (forSpecificToken) {
offendingToken = re.getOffendingToken().getType();
}
if (situations.containsKey(new ErrorSituation(offendingState, offendingToken))) {
int j = situations.get(new ErrorSituation(offendingState, offendingToken));
String thatMessage = (String)errorExamples()[j][1];
if (! Objects.equals(message, thatMessage)) {
// TODO show the message in eclipse
throw new RuntimeException(
String.format(
"duplicate error situations: state: %s, token: %s;\n\tquery: \"%s\", message: \"%s\";\n\tquery: \"%s\", message: \"%s\"",
offendingState,
offendingToken != null && offendingToken != -1 ? String.format("%s (%d)",ruleNames()[offendingToken-1],offendingToken) : String.format("%3d", offendingToken),
((String)errorExamples()[j][0]).replace("\"","\\\""),
thatMessage.replace("\"","\\\""),
query.replace("\"","\\\"").replace("\n","\\n"),
message.replace("\"","\\\"").replace("\n","\\n")
)
);
} else {
return;
}
}
situations.put(new ErrorSituation(offendingState, offendingToken), i);
Object tokenR = offendingToken != null && offendingToken != -1 ? ruleNames()[offendingToken-1] : offendingToken;
sb.append(
String.format(
" .put(new ErrorSituation(%3d, %s), \"%s\")\t//%s\t\t\t//%s\n",
offendingState,