code: protected void reportSyntaxError(JCDiagnostic.DiagnosticPosition diagPos, String key, Object... args) {
          int pos = diagPos.getPreferredPosition();
          if (pos > S.errPos() || pos == Position.NOPOS) {
              if (token.kind == EOF) {
                  error(diagPos, "premature.eof");
              } else {
                  error(diagPos, key, args);
              }
          }
          S.errPos(pos);
          if (token.pos == errorPos) {
              //check for a possible infinite loop in parsing:
              Assert.check(count++ < RECOVERY_THRESHOLD);
          } else {
              count = 0;
              errorPos = token.pos;
          }
      }
docs: Report a syntax error using the given DiagnosticPosition object and
  arguments, unless one was already reported at the same position.