code: private void nextFromPrologBang(boolean isProlog)
          throws XMLStreamException
      {
          int i = getNext();
          if (i < 0) {
              throwUnexpectedEOF(SUFFIX_IN_PROLOG);
          }
          if (i == 'D') { // Doctype declaration?
              String keyw = checkKeyword('D', "DOCTYPE");
              if (keyw != null) {
                  throwParseError("Unrecognized XML directive '<!"+keyw+"' (misspelled DOCTYPE?).");
              }
              
              if (!isProlog) {
                  // Still possibly ok in multidoc mode...
                  if (mConfig.inputParsingModeDocuments()) {
                      if (!mStDoctypeFound) {
                          mCurrToken = handleMultiDocStart(DTD);
                          return;
                      }
                  } else {
                      throwParseError(ErrorConsts.ERR_DTD_IN_EPILOG);
                  }
              }
              if (mStDoctypeFound) {
                  throwParseError(ErrorConsts.ERR_DTD_DUP);
              }
              mStDoctypeFound = true;
              // Ok; let's read main input (all but internal subset)
              mCurrToken = DTD;
              startDTD();
              return;
          } else if (i == '-') { // comment
              char c = getNextChar(isProlog ? SUFFIX_IN_PROLOG : SUFFIX_IN_EPILOG);
              if (c != '-') {
                  throwUnexpectedChar(i, " (malformed comment?)");
              }
              // Likewise, let's delay actual parsing/skipping.
              mTokenState = TOKEN_STARTED;
              mCurrToken = COMMENT;
              return;
          } else if (i == '[') { // erroneous CDATA?
              i = peekNext();
              // Let's just add bit of heuristics, to get better error msg
              if (i == 'C') {
                  throwUnexpectedChar(i, ErrorConsts.ERR_CDATA_IN_EPILOG);
              }
          }
  
          throwUnexpectedChar(i, " after '<!' (malformed comment?)");
      }
docs: Called after character sequence '&lt;!' has been found; expectation is
  that it'll either be DOCTYPE declaration (if we are in prolog and
  haven't yet seen one), or a comment. CDATA is not legal here;
  it would start same way otherwise.