parseDocument method

Document? parseDocument()

Implementation

Document? parseDocument() {
  // Pula comentários e textos só-whitespace antes do DOCTYPE/raiz
  _skipPreamble();

  var doctype = parseDoctype();

  // Pula comentários/whitespace entre DOCTYPE e a raiz
  _skipPreamble();

  var root = parseElement();

  if (root == null) {
    // Mantém o comportamento antigo de só reportar se havia DOCTYPE
    if (doctype != null) {
      errors.add(JaelError(
        JaelErrorSeverity.error,
        'Missing root element after !DOCTYPE declaration.',
        doctype.span,
      ));
    }
    return null;
  }

  return Document(doctype, root);
}