📄 qxmlstream_p.h
字号:
case ']': token = RBRACK; break; case '(': token = LPAREN; break; case ')': token = RPAREN; break; case '|': token = PIPE; break; case '=': token = EQ; break; case '%': token = PERCENT; break; case '/': token = SLASH; break; case ':': token = COLON; break; case ';': token = SEMICOLON; break; case ',': token = COMMA; break; case '-': token = DASH; break; case '+': token = PLUS; break; case '*': token = STAR; break; case '.': token = DOT; break; case '?': token = QUESTIONMARK; break; case '!': token = BANG; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': token = DIGIT; break; default: if (cu < 0x20) token = NOTOKEN; else token = LETTER; break; } } act = t_action (act, token); if (act == ACCEPT_STATE) { // reset the parser in case someone resumes (process instructions can follow a valid document) tos = 0; state_stack[tos++] = 0; state_stack[tos] = 0; return true; } else if (act > 0) { if (++tos == stack_size) reallocateStack(); Value &val = sym_stack[tos]; val.c = token_char; val.pos = textBuffer.size(); val.prefix = 0; val.len = 1; if (token_char) textBuffer.inline_append(token_char); state_stack[tos] = act; token = -1; } else if (act < 0) { r = - act - 1;#if defined (QLALR_DEBUG) int ridx = rule_index[r]; printf ("%3d) %s ::=", r + 1, spell[rule_info[ridx]]); ++ridx; for (int i = ridx; i < ridx + rhs[r]; ++i) { int symbol = rule_info[i]; if (const char *name = spell[symbol]) printf (" %s", name); else printf (" #%d", symbol); } printf ("\n");#endif tos -= rhs[r]; act = state_stack[tos++]; ResumeReduction: switch (r) { case 0: setType(QXmlStreamReader::EndDocument); break; case 1: if (type != QXmlStreamReader::Invalid) { if (hasSeenTag || inParseEntity) { setType(QXmlStreamReader::EndDocument); } else { raiseError(QXmlStreamReader::PrematureEndOfDocumentError, QXmlStream::tr("Start tag expected.")); // reset the parser tos = 0; state_stack[tos++] = 0; state_stack[tos] = 0; return false; } } break; case 10: entityReferenceStack.pop()->isCurrentlyReferenced = false; clearSym(); break; case 11: if (!scanString(spell[VERSION], VERSION, false) && atEnd) { resume(11); return false; } break; case 12: setType(QXmlStreamReader::StartDocument); startDocument(symString(6)); break; case 13: hasExternalDtdSubset = true; break; case 14: checkPublicLiteral(symString(2)); hasExternalDtdSubset = true; break; case 16: if (!scanPublicOrSystem() && atEnd) { resume(16); return false; } break; case 17: case 18: case 19: case 20: setType(QXmlStreamReader::DTD); text = &textBuffer; break; case 21: scanDtd = true; break; case 22: scanDtd = false; break; case 36: if (!scanString(spell[EMPTY], EMPTY, false) && !scanString(spell[ANY], ANY, false) && atEnd) { resume(36); return false; } break; case 42: if (!scanString(spell[PCDATA], PCDATA, false) && atEnd) { resume(42); return false; } break; case 67: { lastAttributeIsCData = true; } break; case 77: if (!scanAfterDefaultDecl() && atEnd) { resume(77); return false; } break; case 82: sym(1) = sym(2); lastAttributeValue.clear(); lastAttributeIsCData = false; if (!scanAttType() && atEnd) { resume(82); return false; } break; case 83: { DtdAttribute &dtdAttribute = dtdAttributes.push(); dtdAttribute.tagName.clear(); dtdAttribute.isCDATA = lastAttributeIsCData; dtdAttribute.attributePrefix = addToStringStorage(symPrefix(1)); dtdAttribute.attributeName = addToStringStorage(symString(1)); dtdAttribute.attributeQualifiedName = addToStringStorage(symName(1)); if (lastAttributeValue.isNull()) { dtdAttribute.defaultValue.clear(); } else { if (dtdAttribute.isCDATA) dtdAttribute.defaultValue = addToStringStorage(lastAttributeValue); else dtdAttribute.defaultValue = addToStringStorage(lastAttributeValue.toString().simplified()); } } break; case 87: { if (referenceToUnparsedEntityDetected && !standalone) break; int n = dtdAttributes.size(); QStringRef tagName = addToStringStorage(symString(3)); while (n--) { DtdAttribute &dtdAttribute = dtdAttributes[n]; if (!dtdAttribute.tagName.isNull()) break; dtdAttribute.tagName = tagName; for (int i = 0; i < n; ++i) { if ((dtdAttributes[i].tagName.isNull() || dtdAttributes[i].tagName == tagName) && dtdAttributes[i].attributeQualifiedName == dtdAttribute.attributeQualifiedName) { dtdAttribute.attributeQualifiedName.clear(); // redefined, delete it break; } } } } break; case 88: { if (!scanPublicOrSystem() && atEnd) { resume(88); return false; } EntityDeclaration &entityDeclaration = entityDeclarations.push(); entityDeclaration.clear(); entityDeclaration.name = symString(3); } break; case 89: { if (!scanPublicOrSystem() && atEnd) { resume(89); return false; } EntityDeclaration &entityDeclaration = entityDeclarations.push(); entityDeclaration.clear(); entityDeclaration.name = symString(5); entityDeclaration.parameter = true; } break; case 90: { if (!scanNData() && atEnd) { resume(90); return false; } EntityDeclaration &entityDeclaration = entityDeclarations.top(); entityDeclaration.systemId = symString(3); entityDeclaration.external = true; } break; case 91: { if (!scanNData() && atEnd) { resume(91); return false; } EntityDeclaration &entityDeclaration = entityDeclarations.top(); checkPublicLiteral((entityDeclaration.publicId = symString(3))); entityDeclaration.systemId = symString(5); entityDeclaration.external = true; } break; case 92: { EntityDeclaration &entityDeclaration = entityDeclarations.top(); entityDeclaration.notationName = symString(3); if (entityDeclaration.parameter) raiseWellFormedError(QXmlStream::tr("NDATA in parameter entity declaration.")); } //fall through case 93: case 94: { if (referenceToUnparsedEntityDetected && !standalone) { entityDeclarations.pop(); break; } EntityDeclaration &entityDeclaration = entityDeclarations.top(); if (!entityDeclaration.external) entityDeclaration.value = symString(2); QString entityName = entityDeclaration.name.toString(); QHash<QString, Entity> &hash = entityDeclaration.parameter ? parameterEntityHash : entityHash; if (!hash.contains(entityName)) { Entity entity(entityDeclaration.value.toString()); entity.unparsed = (!entityDeclaration.notationName.isNull()); entity.external = entityDeclaration.external; hash.insert(entityName, entity); } } break; case 95: { setType(QXmlStreamReader::ProcessingInstruction); int pos = sym(4).pos + sym(4).len; processingInstructionTarget = symString(3); if (scanUntil("?>")) { processingInstructionData = QStringRef(&textBuffer, pos, textBuffer.size() - pos - 2); const QString piTarget(processingInstructionTarget.toString()); if (!piTarget.compare(QLatin1String("xml"), Qt::CaseInsensitive)) { raiseWellFormedError(QXmlStream::tr("XML declaration not at start of document.")); } else if(!QXmlUtils::isNCName(piTarget)) raiseWellFormedError(QXmlStream::tr("%1 is an invalid processing instruction name.").arg(piTarget)); } else if (type != QXmlStreamReader::Invalid){ resume(95); return false; } } break; case 96: setType(QXmlStreamReader::ProcessingInstruction); processingInstructionTarget = symString(3); if (!processingInstructionTarget.toString().compare(QLatin1String("xml"), Qt::CaseInsensitive)) raiseWellFormedError(QXmlStream::tr("Invalid processing instruction name.")); break; case 97: if (!scanAfterLangleBang() && atEnd) { resume(97); return false; } break; case 98: if (!scanUntil("--")) { resume(98); return false; } break; case 99: { setType(QXmlStreamReader::Comment); int pos = sym(1).pos + 4; text = QStringRef(&textBuffer, pos, textBuffer.size() - pos - 3); } break; case 100: { setType(QXmlStreamReader::Characters); isCDATA = true; int pos = sym(2).pos; if (scanUntil("]]>", -1)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -