src/corelib/xml/qxmlstream.g
changeset 0 1918ee327afb
child 3 41300fa6a67c
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 ----------------------------------------------------------------------------
       
     2 --
       
     3 -- Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 -- All rights reserved.
       
     5 -- Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 --
       
     7 -- This file is part of the QtCore module of the Qt Toolkit.
       
     8 --
       
     9 -- $QT_BEGIN_LICENSE:LGPL$
       
    10 -- No Commercial Usage
       
    11 -- This file contains pre-release code and may not be distributed.
       
    12 -- You may use this file in accordance with the terms and conditions
       
    13 -- contained in the Technology Preview License Agreement accompanying
       
    14 -- this package.
       
    15 --
       
    16 -- GNU Lesser General Public License Usage
       
    17 -- Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 -- General Public License version 2.1 as published by the Free Software
       
    19 -- Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 -- packaging of this file.  Please review the following information to
       
    21 -- ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 -- will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 --
       
    24 -- In addition, as a special exception, Nokia gives you certain additional
       
    25 -- rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 -- version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 --
       
    28 -- If you have questions regarding the use of this file, please contact
       
    29 -- Nokia at qt-info@nokia.com.
       
    30 --
       
    31 --
       
    32 --
       
    33 --
       
    34 --
       
    35 --
       
    36 --
       
    37 --
       
    38 -- $QT_END_LICENSE$
       
    39 --
       
    40 ----------------------------------------------------------------------------
       
    41 
       
    42 %parser QXmlStreamReader_Table
       
    43 
       
    44 %merged_output qxmlstream_p.h
       
    45 
       
    46 %token NOTOKEN
       
    47 %token SPACE " "
       
    48 %token LANGLE "<"
       
    49 %token RANGLE ">"
       
    50 %token AMPERSAND "&"
       
    51 %token HASH "#"
       
    52 %token QUOTE "\'"
       
    53 %token DBLQUOTE "\""
       
    54 %token LBRACK "["
       
    55 %token RBRACK "]"
       
    56 %token LPAREN "("
       
    57 %token RPAREN ")"
       
    58 %token PIPE "|"
       
    59 %token EQ "="
       
    60 %token PERCENT "%"
       
    61 %token SLASH "/"
       
    62 %token COLON ":"
       
    63 %token SEMICOLON ";"
       
    64 %token COMMA ","
       
    65 %token DASH "-"
       
    66 %token PLUS "+"
       
    67 %token STAR "*"
       
    68 %token DOT "."
       
    69 %token QUESTIONMARK "?"
       
    70 %token BANG "!"
       
    71 %token LETTER "[a-zA-Z]"
       
    72 %token DIGIT "[0-9]"
       
    73 
       
    74 -- after langle_bang
       
    75 %token CDATA_START "[CDATA["
       
    76 %token DOCTYPE "DOCTYPE"
       
    77 %token ELEMENT "ELEMENT"
       
    78 %token ATTLIST "ATTLIST"
       
    79 %token ENTITY "ENTITY"
       
    80 %token NOTATION "NOTATION"
       
    81 
       
    82 -- entity decl
       
    83 %token SYSTEM "SYSTEM"
       
    84 %token PUBLIC "PUBLIC"
       
    85 %token NDATA "NDATA"
       
    86 
       
    87 -- default decl
       
    88 %token REQUIRED "REQUIRED"
       
    89 %token IMPLIED "IMPLIED"
       
    90 %token FIXED "FIXED"
       
    91 
       
    92 -- conent spec
       
    93 %token EMPTY "EMPTY"
       
    94 %token ANY "ANY"
       
    95 %token PCDATA "PCDATA"
       
    96 
       
    97 -- error
       
    98 %token ERROR
       
    99 
       
   100 -- entities
       
   101 %token PARSE_ENTITY
       
   102 %token ENTITY_DONE
       
   103 %token UNRESOLVED_ENTITY
       
   104 
       
   105 -- att type
       
   106 %token CDATA "CDATA"
       
   107 %token ID "ID"
       
   108 %token IDREF "IDREF"
       
   109 %token IDREFS "IDREFS"
       
   110 %token ENTITY "ENTITY"
       
   111 %token ENTITIES "ENTITIES"
       
   112 %token NMTOKEN "NMTOKEN"
       
   113 %token NMTOKENS "NMTOKENS"
       
   114 
       
   115 -- xml declaration
       
   116 %token XML "<?xml"
       
   117 %token VERSION "version"
       
   118 
       
   119 %nonassoc SHIFT_THERE
       
   120 %nonassoc AMPERSAND
       
   121           BANG
       
   122           COLON
       
   123           COMMA
       
   124           DASH
       
   125           DBLQUOTE
       
   126           DIGIT
       
   127           DOT
       
   128           ENTITY_DONE
       
   129           EQ
       
   130           HASH
       
   131           LBRACK
       
   132           LETTER
       
   133           LPAREN
       
   134           PERCENT
       
   135           PIPE
       
   136           PLUS
       
   137           QUESTIONMARK
       
   138           QUOTE
       
   139           RANGLE
       
   140           RBRACK
       
   141           RPAREN
       
   142           SEMICOLON
       
   143           SLASH
       
   144           SPACE
       
   145           STAR
       
   146 
       
   147 %start document
       
   148 
       
   149 /.
       
   150 template <typename T> class QXmlStreamSimpleStack {
       
   151     T *data;
       
   152     int tos, cap;
       
   153 public:
       
   154     inline QXmlStreamSimpleStack():data(0), tos(-1), cap(0){}
       
   155     inline ~QXmlStreamSimpleStack(){ if (data) qFree(data); }
       
   156 
       
   157     inline void reserve(int extraCapacity) {
       
   158         if (tos + extraCapacity + 1 > cap) {
       
   159             cap = qMax(tos + extraCapacity + 1, cap << 1 );
       
   160             data = reinterpret_cast<T *>(qRealloc(data, cap * sizeof(T)));
       
   161         }
       
   162     }
       
   163 
       
   164     inline T &push() { reserve(1); return data[++tos]; }
       
   165     inline T &rawPush() { return data[++tos]; }
       
   166     inline const T &top() const { return data[tos]; }
       
   167     inline T &top() { return data[tos]; }
       
   168     inline T &pop() { return data[tos--]; }
       
   169     inline T &operator[](int index) { return data[index]; }
       
   170     inline const T &at(int index) const { return data[index]; }
       
   171     inline int size() const { return tos + 1; }
       
   172     inline void resize(int s) { tos = s - 1; }
       
   173     inline bool isEmpty() const { return tos < 0; }
       
   174     inline void clear() { tos = -1; }
       
   175 };
       
   176 
       
   177 
       
   178 class QXmlStream
       
   179 {
       
   180     Q_DECLARE_TR_FUNCTIONS(QXmlStream)
       
   181 };
       
   182 
       
   183 class QXmlStreamPrivateTagStack {
       
   184 public:
       
   185     struct NamespaceDeclaration
       
   186     {
       
   187         QStringRef prefix;
       
   188         QStringRef namespaceUri;
       
   189     };
       
   190 
       
   191     struct Tag
       
   192     {
       
   193         QStringRef name;
       
   194         QStringRef qualifiedName;
       
   195         NamespaceDeclaration namespaceDeclaration;
       
   196         int tagStackStringStorageSize;
       
   197         int namespaceDeclarationsSize;
       
   198     };
       
   199 
       
   200 
       
   201     QXmlStreamPrivateTagStack();
       
   202     QXmlStreamSimpleStack<NamespaceDeclaration> namespaceDeclarations;
       
   203     QString tagStackStringStorage;
       
   204     int tagStackStringStorageSize;
       
   205     bool tagsDone;
       
   206 
       
   207     inline QStringRef addToStringStorage(const QStringRef &s) {
       
   208         int pos = tagStackStringStorageSize;
       
   209 	int sz = s.size();
       
   210 	if (pos != tagStackStringStorage.size())
       
   211 	    tagStackStringStorage.resize(pos);
       
   212         tagStackStringStorage.insert(pos, s.unicode(), sz);
       
   213         tagStackStringStorageSize += sz;
       
   214         return QStringRef(&tagStackStringStorage, pos, sz);
       
   215     }
       
   216     inline QStringRef addToStringStorage(const QString &s) {
       
   217         int pos = tagStackStringStorageSize;
       
   218 	int sz = s.size();
       
   219 	if (pos != tagStackStringStorage.size())
       
   220 	    tagStackStringStorage.resize(pos);
       
   221         tagStackStringStorage.insert(pos, s.unicode(), sz);
       
   222         tagStackStringStorageSize += sz;
       
   223         return QStringRef(&tagStackStringStorage, pos, sz);
       
   224     }
       
   225 
       
   226     QXmlStreamSimpleStack<Tag> tagStack;
       
   227 
       
   228 
       
   229     inline Tag &tagStack_pop() {
       
   230         Tag& tag = tagStack.pop();
       
   231         tagStackStringStorageSize = tag.tagStackStringStorageSize;
       
   232         namespaceDeclarations.resize(tag.namespaceDeclarationsSize);
       
   233         tagsDone = tagStack.isEmpty();
       
   234         return tag;
       
   235     }
       
   236     inline Tag &tagStack_push() {
       
   237         Tag &tag = tagStack.push();
       
   238         tag.tagStackStringStorageSize = tagStackStringStorageSize;
       
   239         tag.namespaceDeclarationsSize = namespaceDeclarations.size();
       
   240         return tag;
       
   241     }
       
   242 };
       
   243 
       
   244 
       
   245 class QXmlStreamEntityResolver;
       
   246 
       
   247 class QXmlStreamReaderPrivate : public QXmlStreamReader_Table, public QXmlStreamPrivateTagStack{
       
   248     QXmlStreamReader *q_ptr;
       
   249     Q_DECLARE_PUBLIC(QXmlStreamReader)
       
   250 public:
       
   251     QXmlStreamReaderPrivate(QXmlStreamReader *q);
       
   252     ~QXmlStreamReaderPrivate();
       
   253     void init();
       
   254 
       
   255     QByteArray rawReadBuffer;
       
   256     QByteArray dataBuffer;
       
   257     uchar firstByte;
       
   258     qint64 nbytesread;
       
   259     QString readBuffer;
       
   260     int readBufferPos;
       
   261     QXmlStreamSimpleStack<uint> putStack;
       
   262     struct Entity {
       
   263         Entity(const QString& str = QString())
       
   264             :value(str), external(false), unparsed(false), literal(false),
       
   265              hasBeenParsed(false), isCurrentlyReferenced(false){}
       
   266         static inline Entity createLiteral(const QString &entity)
       
   267             { Entity result(entity); result.literal = result.hasBeenParsed = true; return result; }
       
   268         QString value;
       
   269         uint external : 1;
       
   270         uint unparsed : 1;
       
   271         uint literal : 1;
       
   272         uint hasBeenParsed : 1;
       
   273         uint isCurrentlyReferenced : 1;
       
   274     };
       
   275     QHash<QString, Entity> entityHash;
       
   276     QHash<QString, Entity> parameterEntityHash;
       
   277     QXmlStreamSimpleStack<Entity *>entityReferenceStack;
       
   278     inline bool referenceEntity(Entity &entity) {
       
   279         if (entity.isCurrentlyReferenced) {
       
   280             raiseWellFormedError(QXmlStream::tr("Recursive entity detected."));
       
   281             return false;
       
   282         }
       
   283         entity.isCurrentlyReferenced = true;
       
   284         entityReferenceStack.push() = &entity;
       
   285         injectToken(ENTITY_DONE);
       
   286         return true;
       
   287     }
       
   288 
       
   289 
       
   290     QIODevice *device;
       
   291     bool deleteDevice;
       
   292 #ifndef QT_NO_TEXTCODEC
       
   293     QTextCodec *codec;
       
   294     QTextDecoder *decoder;
       
   295 #endif
       
   296     bool atEnd;
       
   297 
       
   298     /*!
       
   299       \sa setType()
       
   300      */
       
   301     QXmlStreamReader::TokenType type;
       
   302     QXmlStreamReader::Error error;
       
   303     QString errorString;
       
   304     QString unresolvedEntity;
       
   305 
       
   306     qint64 lineNumber, lastLineStart, characterOffset;
       
   307 
       
   308 
       
   309     void write(const QString &);
       
   310     void write(const char *);
       
   311 
       
   312 
       
   313     QXmlStreamAttributes attributes;
       
   314     QStringRef namespaceForPrefix(const QStringRef &prefix);
       
   315     void resolveTag();
       
   316     void resolvePublicNamespaces();
       
   317     void resolveDtd();
       
   318     uint resolveCharRef(int symbolIndex);
       
   319     bool checkStartDocument();
       
   320     void startDocument();
       
   321     void parseError();
       
   322     void checkPublicLiteral(const QStringRef &publicId);
       
   323 
       
   324     bool scanDtd;
       
   325     QStringRef lastAttributeValue;
       
   326     bool lastAttributeIsCData;
       
   327     struct DtdAttribute {
       
   328         QStringRef tagName;
       
   329         QStringRef attributeQualifiedName;
       
   330         QStringRef attributePrefix;
       
   331         QStringRef attributeName;
       
   332         QStringRef defaultValue;
       
   333         bool isCDATA;
       
   334         bool isNamespaceAttribute;
       
   335     };
       
   336     QXmlStreamSimpleStack<DtdAttribute> dtdAttributes;
       
   337     struct NotationDeclaration {
       
   338         QStringRef name;
       
   339         QStringRef publicId;
       
   340         QStringRef systemId;
       
   341     };
       
   342     QXmlStreamSimpleStack<NotationDeclaration> notationDeclarations;
       
   343     QXmlStreamNotationDeclarations publicNotationDeclarations;
       
   344     QXmlStreamNamespaceDeclarations publicNamespaceDeclarations;
       
   345 
       
   346     struct EntityDeclaration {
       
   347         QStringRef name;
       
   348         QStringRef notationName;
       
   349         QStringRef publicId;
       
   350         QStringRef systemId;
       
   351         QStringRef value;
       
   352         bool parameter;
       
   353         bool external;
       
   354         inline void clear() {
       
   355             name.clear();
       
   356             notationName.clear();
       
   357             publicId.clear();
       
   358             systemId.clear();
       
   359             value.clear();
       
   360             parameter = external = false;
       
   361         }
       
   362     };
       
   363     QXmlStreamSimpleStack<EntityDeclaration> entityDeclarations;
       
   364     QXmlStreamEntityDeclarations publicEntityDeclarations;
       
   365 
       
   366     QStringRef text;
       
   367 
       
   368     QStringRef prefix, namespaceUri, qualifiedName, name;
       
   369     QStringRef processingInstructionTarget, processingInstructionData;
       
   370     QStringRef dtdName, dtdPublicId, dtdSystemId;
       
   371     QStringRef documentVersion, documentEncoding;
       
   372     uint isEmptyElement : 1;
       
   373     uint isWhitespace : 1;
       
   374     uint isCDATA : 1;
       
   375     uint standalone : 1;
       
   376     uint hasCheckedStartDocument : 1;
       
   377     uint normalizeLiterals : 1;
       
   378     uint hasSeenTag : 1;
       
   379     uint inParseEntity : 1;
       
   380     uint referenceToUnparsedEntityDetected : 1;
       
   381     uint referenceToParameterEntityDetected : 1;
       
   382     uint hasExternalDtdSubset : 1;
       
   383     uint lockEncoding : 1;
       
   384     uint namespaceProcessing : 1;
       
   385 
       
   386     int resumeReduction;
       
   387     void resume(int rule);
       
   388 
       
   389     inline bool entitiesMustBeDeclared() const {
       
   390         return (!inParseEntity
       
   391                 && (standalone
       
   392                     || (!referenceToUnparsedEntityDetected
       
   393                         && !referenceToParameterEntityDetected // Errata 13 as of 2006-04-25
       
   394                         && !hasExternalDtdSubset)));
       
   395     }
       
   396 
       
   397     // qlalr parser
       
   398     int tos;
       
   399     int stack_size;
       
   400     struct Value {
       
   401         int pos;
       
   402         int len;
       
   403         int prefix;
       
   404         ushort c;
       
   405     };
       
   406 
       
   407     Value *sym_stack;
       
   408     int *state_stack;
       
   409     inline void reallocateStack();
       
   410     inline Value &sym(int index) const
       
   411     { return sym_stack[tos + index - 1]; }
       
   412     QString textBuffer;
       
   413     inline void clearTextBuffer() {
       
   414         if (!scanDtd) {
       
   415             textBuffer.resize(0);
       
   416             textBuffer.reserve(256);
       
   417         }
       
   418     }
       
   419     struct Attribute {
       
   420         Value key;
       
   421         Value value;
       
   422     };
       
   423     QXmlStreamSimpleStack<Attribute> attributeStack;
       
   424 
       
   425     inline QStringRef symString(int index) {
       
   426         const Value &symbol = sym(index);
       
   427         return QStringRef(&textBuffer, symbol.pos + symbol.prefix, symbol.len - symbol.prefix);
       
   428     }
       
   429     inline QStringRef symName(int index) {
       
   430         const Value &symbol = sym(index);
       
   431         return QStringRef(&textBuffer, symbol.pos, symbol.len);
       
   432     }
       
   433     inline QStringRef symString(int index, int offset) {
       
   434         const Value &symbol = sym(index);
       
   435         return QStringRef(&textBuffer, symbol.pos + symbol.prefix + offset, symbol.len - symbol.prefix -  offset);
       
   436     }
       
   437     inline QStringRef symPrefix(int index) {
       
   438         const Value &symbol = sym(index);
       
   439         if (symbol.prefix)
       
   440             return QStringRef(&textBuffer, symbol.pos, symbol.prefix - 1);
       
   441         return QStringRef();
       
   442     }
       
   443     inline QStringRef symString(const Value &symbol) {
       
   444         return QStringRef(&textBuffer, symbol.pos + symbol.prefix, symbol.len - symbol.prefix);
       
   445     }
       
   446     inline QStringRef symName(const Value &symbol) {
       
   447         return QStringRef(&textBuffer, symbol.pos, symbol.len);
       
   448     }
       
   449     inline QStringRef symPrefix(const Value &symbol) {
       
   450         if (symbol.prefix)
       
   451             return QStringRef(&textBuffer, symbol.pos, symbol.prefix - 1);
       
   452         return QStringRef();
       
   453     }
       
   454 
       
   455     inline void clearSym() { Value &val = sym(1); val.pos = textBuffer.size(); val.len = 0; }
       
   456 
       
   457 
       
   458     short token;
       
   459     ushort token_char;
       
   460 
       
   461     uint filterCarriageReturn();
       
   462     inline uint getChar();
       
   463     inline uint peekChar();
       
   464     inline void putChar(uint c) { putStack.push() = c; }
       
   465     inline void putChar(QChar c) { putStack.push() =  c.unicode(); }
       
   466     void putString(const QString &s, int from = 0);
       
   467     void putStringLiteral(const QString &s);
       
   468     void putReplacement(const QString &s);
       
   469     void putReplacementInAttributeValue(const QString &s);
       
   470     ushort getChar_helper();
       
   471 
       
   472     bool scanUntil(const char *str, short tokenToInject = -1);
       
   473     bool scanString(const char *str, short tokenToInject, bool requireSpace = true);
       
   474     inline void injectToken(ushort tokenToInject) {
       
   475         putChar(int(tokenToInject) << 16);
       
   476     }
       
   477 
       
   478     QString resolveUndeclaredEntity(const QString &name);
       
   479     void parseEntity(const QString &value);
       
   480     QXmlStreamReaderPrivate *entityParser;
       
   481 
       
   482     bool scanAfterLangleBang();
       
   483     bool scanPublicOrSystem();
       
   484     bool scanNData();
       
   485     bool scanAfterDefaultDecl();
       
   486     bool scanAttType();
       
   487 
       
   488 
       
   489     // scan optimization functions. Not strictly necessary but LALR is
       
   490     // not very well suited for scanning fast
       
   491     int fastScanLiteralContent();
       
   492     int fastScanSpace();
       
   493     int fastScanContentCharList();
       
   494     int fastScanName(int *prefix = 0);
       
   495     inline int fastScanNMTOKEN();
       
   496 
       
   497 
       
   498     bool parse();
       
   499     inline void consumeRule(int);
       
   500 
       
   501     void raiseError(QXmlStreamReader::Error error, const QString& message = QString());
       
   502     void raiseWellFormedError(const QString &message);
       
   503 
       
   504     QXmlStreamEntityResolver *entityResolver;
       
   505 
       
   506 private:
       
   507     /*! \internal
       
   508        Never assign to variable type directly. Instead use this function.
       
   509 
       
   510        This prevents errors from being ignored.
       
   511      */
       
   512     inline void setType(const QXmlStreamReader::TokenType t)
       
   513     {
       
   514         if(type != QXmlStreamReader::Invalid)
       
   515             type = t;
       
   516     }
       
   517 };
       
   518 
       
   519 bool QXmlStreamReaderPrivate::parse()
       
   520 {
       
   521     // cleanup currently reported token
       
   522 
       
   523     switch (type) {
       
   524     case QXmlStreamReader::StartElement:
       
   525         name.clear();
       
   526         prefix.clear();
       
   527 	qualifiedName.clear();
       
   528         namespaceUri.clear();
       
   529         if (publicNamespaceDeclarations.size())
       
   530             publicNamespaceDeclarations.clear();
       
   531         if (attributes.size())
       
   532             attributes.resize(0);
       
   533         if (isEmptyElement) {
       
   534             setType(QXmlStreamReader::EndElement);
       
   535             Tag &tag = tagStack_pop();
       
   536             namespaceUri = tag.namespaceDeclaration.namespaceUri;
       
   537             name = tag.name;
       
   538 	    qualifiedName = tag.qualifiedName;
       
   539             isEmptyElement = false;
       
   540             return true;
       
   541         }
       
   542         clearTextBuffer();
       
   543         break;
       
   544     case QXmlStreamReader::EndElement:
       
   545         name.clear();
       
   546         prefix.clear();
       
   547 	qualifiedName.clear();
       
   548         namespaceUri.clear();
       
   549         clearTextBuffer();
       
   550         break;
       
   551     case QXmlStreamReader::DTD:
       
   552         publicNotationDeclarations.clear();
       
   553         publicEntityDeclarations.clear();
       
   554         dtdName.clear();
       
   555         dtdPublicId.clear();
       
   556         dtdSystemId.clear();
       
   557         // fall through
       
   558     case QXmlStreamReader::Comment:
       
   559     case QXmlStreamReader::Characters:
       
   560         isCDATA = false;
       
   561 	isWhitespace = true;
       
   562         text.clear();
       
   563         clearTextBuffer();
       
   564         break;
       
   565     case QXmlStreamReader::EntityReference:
       
   566         text.clear();
       
   567         name.clear();
       
   568         clearTextBuffer();
       
   569         break;
       
   570     case QXmlStreamReader::ProcessingInstruction:
       
   571         processingInstructionTarget.clear();
       
   572         processingInstructionData.clear();
       
   573 	clearTextBuffer();
       
   574         break;
       
   575     case QXmlStreamReader::NoToken:
       
   576     case QXmlStreamReader::Invalid:
       
   577         break;
       
   578     case QXmlStreamReader::StartDocument:
       
   579 	lockEncoding = true;
       
   580         documentVersion.clear();
       
   581         documentEncoding.clear();
       
   582 #ifndef QT_NO_TEXTCODEC
       
   583 	if(decoder->hasFailure()) {
       
   584 	    raiseWellFormedError(QXmlStream::tr("Encountered incorrectly encoded content."));
       
   585 	    readBuffer.clear();
       
   586 	    return false;
       
   587 	}
       
   588 #endif
       
   589         // fall through
       
   590     default:
       
   591         clearTextBuffer();
       
   592         ;
       
   593     }
       
   594 
       
   595     setType(QXmlStreamReader::NoToken);
       
   596 
       
   597 
       
   598     // the main parse loop
       
   599     int act, r;
       
   600 
       
   601     if (resumeReduction) {
       
   602         act = state_stack[tos-1];
       
   603         r = resumeReduction;
       
   604         resumeReduction = 0;
       
   605         goto ResumeReduction;
       
   606     }
       
   607 
       
   608     act = state_stack[tos];
       
   609 
       
   610     forever {
       
   611         if (token == -1 && - TERMINAL_COUNT != action_index[act]) {
       
   612             uint cu = getChar();
       
   613             token = NOTOKEN;
       
   614             token_char = cu;
       
   615             if (cu & 0xff0000) {
       
   616                 token = cu >> 16;
       
   617             } else switch (token_char) {
       
   618             case 0xfffe:
       
   619             case 0xffff:
       
   620                 token = ERROR;
       
   621                 break;
       
   622             case '\r':
       
   623                 token = SPACE;
       
   624                 if (cu == '\r') {
       
   625                     if ((token_char = filterCarriageReturn())) {
       
   626                         ++lineNumber;
       
   627                         lastLineStart = characterOffset + readBufferPos;
       
   628                         break;
       
   629                     }
       
   630                 } else {
       
   631                     break;
       
   632                 }
       
   633                 // fall through
       
   634             case '\0': {
       
   635                 token = EOF_SYMBOL;
       
   636                 if (!tagsDone && !inParseEntity) {
       
   637                     int a = t_action(act, token);
       
   638                     if (a < 0) {
       
   639                         raiseError(QXmlStreamReader::PrematureEndOfDocumentError);
       
   640                         return false;
       
   641                     }
       
   642                 }
       
   643 
       
   644             } break;
       
   645             case '\n':
       
   646                 ++lineNumber;
       
   647                 lastLineStart = characterOffset + readBufferPos;
       
   648             case ' ':
       
   649             case '\t':
       
   650                 token = SPACE;
       
   651                 break;
       
   652             case '&':
       
   653                 token = AMPERSAND;
       
   654                 break;
       
   655             case '#':
       
   656                 token = HASH;
       
   657                 break;
       
   658             case '\'':
       
   659                 token = QUOTE;
       
   660                 break;
       
   661             case '\"':
       
   662                 token = DBLQUOTE;
       
   663                 break;
       
   664             case '<':
       
   665                 token = LANGLE;
       
   666                 break;
       
   667             case '>':
       
   668                 token = RANGLE;
       
   669                 break;
       
   670             case '[':
       
   671                 token = LBRACK;
       
   672                 break;
       
   673             case ']':
       
   674                 token = RBRACK;
       
   675                 break;
       
   676             case '(':
       
   677                 token = LPAREN;
       
   678                 break;
       
   679             case ')':
       
   680                 token = RPAREN;
       
   681                 break;
       
   682             case '|':
       
   683                 token = PIPE;
       
   684                 break;
       
   685             case '=':
       
   686                 token = EQ;
       
   687                 break;
       
   688             case '%':
       
   689                 token = PERCENT;
       
   690                 break;
       
   691             case '/':
       
   692                 token = SLASH;
       
   693                 break;
       
   694             case ':':
       
   695                 token = COLON;
       
   696                 break;
       
   697             case ';':
       
   698                 token = SEMICOLON;
       
   699                 break;
       
   700             case ',':
       
   701                 token = COMMA;
       
   702                 break;
       
   703             case '-':
       
   704                 token = DASH;
       
   705                 break;
       
   706             case '+':
       
   707                 token = PLUS;
       
   708                 break;
       
   709             case '*':
       
   710                 token = STAR;
       
   711                 break;
       
   712             case '.':
       
   713                 token = DOT;
       
   714                 break;
       
   715             case '?':
       
   716                 token = QUESTIONMARK;
       
   717                 break;
       
   718             case '!':
       
   719                 token = BANG;
       
   720                 break;
       
   721             case '0':
       
   722             case '1':
       
   723             case '2':
       
   724             case '3':
       
   725             case '4':
       
   726             case '5':
       
   727             case '6':
       
   728             case '7':
       
   729             case '8':
       
   730             case '9':
       
   731                 token = DIGIT;
       
   732                 break;
       
   733             default:
       
   734                 if (cu < 0x20)
       
   735                     token = NOTOKEN;
       
   736                 else
       
   737                     token = LETTER;
       
   738                 break;
       
   739             }
       
   740         }
       
   741 
       
   742         act = t_action (act, token);
       
   743         if (act == ACCEPT_STATE) {
       
   744             // reset the parser in case someone resumes (process instructions can follow a valid document)
       
   745             tos = 0;
       
   746             state_stack[tos++] = 0;
       
   747             state_stack[tos] = 0;
       
   748             return true;
       
   749         } else if (act > 0) {
       
   750             if (++tos == stack_size)
       
   751                 reallocateStack();
       
   752 
       
   753             Value &val = sym_stack[tos];
       
   754             val.c = token_char;
       
   755             val.pos = textBuffer.size();
       
   756             val.prefix = 0;
       
   757             val.len = 1;
       
   758             if (token_char)
       
   759                 textBuffer += QChar(token_char);
       
   760 
       
   761             state_stack[tos] = act;
       
   762             token = -1;
       
   763 
       
   764 
       
   765         } else if (act < 0) {
       
   766             r = - act - 1;
       
   767 
       
   768 #if defined (QLALR_DEBUG)
       
   769             int ridx = rule_index[r];
       
   770             printf ("%3d) %s ::=", r + 1, spell[rule_info[ridx]]);
       
   771             ++ridx;
       
   772             for (int i = ridx; i < ridx + rhs[r]; ++i) {
       
   773                 int symbol = rule_info[i];
       
   774                 if (const char *name = spell[symbol])
       
   775                     printf (" %s", name);
       
   776                 else
       
   777                     printf (" #%d", symbol);
       
   778             }
       
   779             printf ("\n");
       
   780 #endif
       
   781 
       
   782             tos -= rhs[r];
       
   783             act = state_stack[tos++];
       
   784         ResumeReduction:
       
   785             switch (r) {
       
   786 ./
       
   787 
       
   788 document ::= PARSE_ENTITY content;
       
   789 /.
       
   790         case $rule_number:
       
   791             setType(QXmlStreamReader::EndDocument);
       
   792         break;
       
   793 ./
       
   794 
       
   795 document ::= prolog;
       
   796 /.
       
   797         case $rule_number:
       
   798             if (type != QXmlStreamReader::Invalid) {
       
   799                 if (hasSeenTag || inParseEntity) {
       
   800                     setType(QXmlStreamReader::EndDocument);
       
   801                 } else {
       
   802                     raiseError(QXmlStreamReader::NotWellFormedError, QXmlStream::tr("Start tag expected."));
       
   803                     // reset the parser
       
   804                     tos = 0;
       
   805                     state_stack[tos++] = 0;
       
   806                     state_stack[tos] = 0;
       
   807                     return false;
       
   808                 }
       
   809             }
       
   810         break;
       
   811 ./
       
   812 
       
   813 
       
   814 prolog ::= prolog stag content etag;
       
   815 prolog ::= prolog empty_element_tag;
       
   816 prolog ::= prolog comment;
       
   817 prolog ::= prolog xml_decl;
       
   818 prolog ::= prolog processing_instruction;
       
   819 prolog ::= prolog doctype_decl;
       
   820 prolog ::= prolog SPACE;
       
   821 prolog ::=;
       
   822 
       
   823 entity_done ::= ENTITY_DONE;
       
   824 /.
       
   825         case $rule_number:
       
   826             entityReferenceStack.pop()->isCurrentlyReferenced = false;
       
   827             clearSym();
       
   828         break;
       
   829 ./
       
   830 
       
   831 
       
   832 xml_decl_start ::= XML;
       
   833 /.
       
   834         case $rule_number:
       
   835             if (!scanString(spell[VERSION], VERSION, false) && atEnd) {
       
   836                 resume($rule_number);
       
   837                 return false;
       
   838             }
       
   839         break;
       
   840 ./
       
   841 
       
   842 xml_decl ::= xml_decl_start VERSION space_opt EQ space_opt literal attribute_list_opt QUESTIONMARK RANGLE;
       
   843 /.
       
   844         case $rule_number:
       
   845             setType(QXmlStreamReader::StartDocument);
       
   846             documentVersion = symString(6);
       
   847             startDocument();
       
   848         break;
       
   849 ./
       
   850 
       
   851 external_id ::= SYSTEM literal;
       
   852 /.
       
   853         case $rule_number:
       
   854             hasExternalDtdSubset = true;
       
   855             dtdSystemId = symString(2);
       
   856         break;
       
   857 ./
       
   858 external_id ::= PUBLIC public_literal space literal;
       
   859 /.
       
   860         case $rule_number:
       
   861             checkPublicLiteral(symString(2));
       
   862             dtdPublicId = symString(2);
       
   863             dtdSystemId = symString(4);
       
   864             hasExternalDtdSubset = true;
       
   865         break;
       
   866 ./
       
   867 external_id ::=;
       
   868 
       
   869 doctype_decl_start ::= langle_bang DOCTYPE qname space;
       
   870 /.
       
   871         case $rule_number:
       
   872             if (!scanPublicOrSystem() && atEnd) {
       
   873                 resume($rule_number);
       
   874                 return false;
       
   875             }
       
   876             dtdName = symString(3);
       
   877         break;
       
   878 ./
       
   879 
       
   880 doctype_decl ::= langle_bang DOCTYPE qname RANGLE;
       
   881 /.
       
   882         case $rule_number:./
       
   883 doctype_decl ::= langle_bang DOCTYPE qname markup space_opt RANGLE;
       
   884 /.
       
   885         case $rule_number:
       
   886             dtdName = symString(3);
       
   887             // fall through
       
   888 ./
       
   889 doctype_decl ::= doctype_decl_start external_id space_opt markup space_opt RANGLE;
       
   890 /.
       
   891         case $rule_number:./
       
   892 doctype_decl ::= doctype_decl_start external_id space_opt RANGLE;
       
   893 /.
       
   894         case $rule_number:
       
   895             setType(QXmlStreamReader::DTD);
       
   896             text = &textBuffer;
       
   897         break;
       
   898 ./
       
   899 
       
   900 markup_start ::= LBRACK;
       
   901 /.
       
   902         case $rule_number:
       
   903             scanDtd = true;
       
   904         break;
       
   905 ./
       
   906 
       
   907 markup ::= markup_start markup_list RBRACK;
       
   908 /.
       
   909         case $rule_number:
       
   910             scanDtd = false;
       
   911         break;
       
   912 ./
       
   913 
       
   914 
       
   915 markup_list ::= markup_decl | space | pereference;
       
   916 markup_list ::= markup_list markup_decl | markup_list space | markup_list pereference;
       
   917 
       
   918 markup_decl ::= element_decl | attlist_decl | entity_decl | entity_done | notation_decl | processing_instruction | comment;
       
   919 
       
   920 
       
   921 element_decl_start ::= langle_bang ELEMENT qname space;
       
   922 /.
       
   923         case $rule_number:
       
   924             if (!scanString(spell[EMPTY], EMPTY, false)
       
   925                 && !scanString(spell[ANY], ANY, false)
       
   926                 && atEnd) {
       
   927                 resume($rule_number);
       
   928                 return false;
       
   929             }
       
   930         break;
       
   931 ./
       
   932 
       
   933 element_decl ::= element_decl_start content_spec space_opt RANGLE;
       
   934 
       
   935 
       
   936 content_spec ::= EMPTY | ANY | mixed | children;
       
   937 
       
   938 pcdata_start ::= HASH;
       
   939 /.
       
   940         case $rule_number:
       
   941             if (!scanString(spell[PCDATA], PCDATA, false) && atEnd) {
       
   942                 resume($rule_number);
       
   943                 return false;
       
   944             }
       
   945         break;
       
   946 ./
       
   947 
       
   948 pcdata ::= pcdata_start PCDATA;
       
   949 
       
   950 questionmark_or_star_or_plus_opt ::= QUESTIONMARK | STAR | PLUS;
       
   951 questionmark_or_star_or_plus_opt ::=;
       
   952 
       
   953 cp ::= qname questionmark_or_star_or_plus_opt | choice_or_seq questionmark_or_star_or_plus_opt;
       
   954 
       
   955 cp_pipe_or_comma_list ::= cp space_opt;
       
   956 cp_pipe_or_comma_list ::= cp space_opt PIPE space_opt cp_pipe_list space_opt;
       
   957 cp_pipe_or_comma_list ::= cp space_opt COMMA space_opt cp_comma_list space_opt;
       
   958 cp_pipe_list ::= cp | cp_pipe_list space_opt PIPE space_opt cp;
       
   959 cp_comma_list ::= cp | cp_comma_list space_opt COMMA space_opt cp;
       
   960 
       
   961 
       
   962 name_pipe_list ::= PIPE space_opt qname;
       
   963 name_pipe_list ::= name_pipe_list space_opt PIPE space_opt qname;
       
   964 
       
   965 star_opt ::= | STAR;
       
   966 
       
   967 mixed ::= LPAREN space_opt pcdata space_opt RPAREN star_opt;
       
   968 mixed ::= LPAREN space_opt pcdata space_opt name_pipe_list space_opt RPAREN STAR;
       
   969 
       
   970 choice_or_seq ::= LPAREN space_opt cp_pipe_or_comma_list RPAREN;
       
   971 
       
   972 children ::= choice_or_seq questionmark_or_star_or_plus_opt;
       
   973 
       
   974 
       
   975 nmtoken_pipe_list ::= nmtoken;
       
   976 nmtoken_pipe_list ::= nmtoken_pipe_list space_opt PIPE space_opt nmtoken;
       
   977 
       
   978 
       
   979 att_type ::= CDATA;
       
   980 /.
       
   981         case $rule_number: {
       
   982             lastAttributeIsCData = true;
       
   983         } break;
       
   984 ./
       
   985 att_type ::= ID | IDREF | IDREFS | ENTITY | ENTITIES | NMTOKEN | NMTOKENS;
       
   986 att_type ::= LPAREN space_opt nmtoken_pipe_list space_opt RPAREN space;
       
   987 att_type ::= NOTATION LPAREN space_opt nmtoken_pipe_list space_opt RPAREN space;
       
   988 
       
   989 
       
   990 default_declhash ::= HASH;
       
   991 /.
       
   992         case $rule_number:
       
   993             if (!scanAfterDefaultDecl() && atEnd) {
       
   994                 resume($rule_number);
       
   995                 return false;
       
   996             }
       
   997         break;
       
   998 ./
       
   999 
       
  1000 default_decl ::= default_declhash REQUIRED;
       
  1001 default_decl ::= default_declhash IMPLIED;
       
  1002 default_decl ::= attribute_value;
       
  1003 default_decl ::= default_declhash FIXED space attribute_value;
       
  1004 attdef_start ::= space qname space;
       
  1005 /.
       
  1006         case $rule_number:
       
  1007                 sym(1) = sym(2);
       
  1008                 lastAttributeValue.clear();
       
  1009                 lastAttributeIsCData = false;
       
  1010                 if (!scanAttType() && atEnd) {
       
  1011                     resume($rule_number);
       
  1012                     return false;
       
  1013                 }
       
  1014         break;
       
  1015 ./
       
  1016 
       
  1017 attdef ::= attdef_start att_type default_decl;
       
  1018 /.
       
  1019         case $rule_number: {
       
  1020             DtdAttribute &dtdAttribute = dtdAttributes.push();
       
  1021             dtdAttribute.tagName.clear();
       
  1022             dtdAttribute.isCDATA = lastAttributeIsCData;
       
  1023             dtdAttribute.attributePrefix = addToStringStorage(symPrefix(1));
       
  1024             dtdAttribute.attributeName = addToStringStorage(symString(1));
       
  1025             dtdAttribute.attributeQualifiedName = addToStringStorage(symName(1));
       
  1026             dtdAttribute.isNamespaceAttribute = (dtdAttribute.attributePrefix == QLatin1String("xmlns")
       
  1027                                                  || (dtdAttribute.attributePrefix.isEmpty()
       
  1028                                                      && dtdAttribute.attributeName == QLatin1String("xmlns")));
       
  1029             if (lastAttributeValue.isNull()) {
       
  1030                 dtdAttribute.defaultValue.clear();
       
  1031             } else {
       
  1032                 if (dtdAttribute.isCDATA)
       
  1033                     dtdAttribute.defaultValue = addToStringStorage(lastAttributeValue);
       
  1034                 else
       
  1035                     dtdAttribute.defaultValue = addToStringStorage(lastAttributeValue.toString().simplified());
       
  1036 
       
  1037             }
       
  1038         } break;
       
  1039 ./
       
  1040 
       
  1041 attdef_list ::= attdef;
       
  1042 attdef_list ::= attdef_list attdef;
       
  1043 
       
  1044 attlist_decl ::= langle_bang ATTLIST qname space_opt RANGLE;
       
  1045 attlist_decl ::= langle_bang ATTLIST qname attdef_list space_opt RANGLE;
       
  1046 /.
       
  1047         case $rule_number: {
       
  1048             if (referenceToUnparsedEntityDetected && !standalone)
       
  1049                 break;
       
  1050             int n = dtdAttributes.size();
       
  1051             QStringRef tagName = addToStringStorage(symName(3));
       
  1052             while (n--) {
       
  1053                 DtdAttribute &dtdAttribute = dtdAttributes[n];
       
  1054                 if (!dtdAttribute.tagName.isNull())
       
  1055                     break;
       
  1056                 dtdAttribute.tagName = tagName;
       
  1057                 for (int i = 0; i < n; ++i) {
       
  1058                     if ((dtdAttributes[i].tagName.isNull() || dtdAttributes[i].tagName == tagName)
       
  1059                         && dtdAttributes[i].attributeQualifiedName == dtdAttribute.attributeQualifiedName) {
       
  1060                         dtdAttribute.attributeQualifiedName.clear(); // redefined, delete it
       
  1061                         break;
       
  1062                     }
       
  1063                 }
       
  1064             }
       
  1065         } break;
       
  1066 ./
       
  1067 
       
  1068 entity_decl_start ::= langle_bang ENTITY name space;
       
  1069 /.
       
  1070         case $rule_number: {
       
  1071             if (!scanPublicOrSystem() && atEnd) {
       
  1072                 resume($rule_number);
       
  1073                 return false;
       
  1074             }
       
  1075             EntityDeclaration &entityDeclaration = entityDeclarations.push();
       
  1076             entityDeclaration.clear();
       
  1077             entityDeclaration.name = symString(3);
       
  1078         } break;
       
  1079 ./
       
  1080 
       
  1081 entity_decl_start ::= langle_bang ENTITY PERCENT space name space;
       
  1082 /.
       
  1083         case $rule_number: {
       
  1084             if (!scanPublicOrSystem() && atEnd) {
       
  1085                 resume($rule_number);
       
  1086                 return false;
       
  1087             }
       
  1088             EntityDeclaration &entityDeclaration = entityDeclarations.push();
       
  1089             entityDeclaration.clear();
       
  1090             entityDeclaration.name = symString(5);
       
  1091             entityDeclaration.parameter = true;
       
  1092         } break;
       
  1093 ./
       
  1094 
       
  1095 entity_decl_external ::= entity_decl_start SYSTEM literal;
       
  1096 /.
       
  1097         case $rule_number: {
       
  1098             if (!scanNData() && atEnd) {
       
  1099                 resume($rule_number);
       
  1100                 return false;
       
  1101             }
       
  1102             EntityDeclaration &entityDeclaration = entityDeclarations.top();
       
  1103             entityDeclaration.systemId = symString(3);
       
  1104             entityDeclaration.external = true;
       
  1105         } break;
       
  1106 ./
       
  1107 
       
  1108 entity_decl_external ::= entity_decl_start PUBLIC public_literal space literal;
       
  1109 /.
       
  1110         case $rule_number: {
       
  1111             if (!scanNData() && atEnd) {
       
  1112                 resume($rule_number);
       
  1113                 return false;
       
  1114             }
       
  1115             EntityDeclaration &entityDeclaration = entityDeclarations.top();
       
  1116             checkPublicLiteral((entityDeclaration.publicId = symString(3)));
       
  1117             entityDeclaration.systemId = symString(5);
       
  1118             entityDeclaration.external = true;
       
  1119         } break;
       
  1120 ./
       
  1121 
       
  1122 entity_decl ::= entity_decl_external NDATA name space_opt RANGLE;
       
  1123 /.
       
  1124         case $rule_number: {
       
  1125             EntityDeclaration &entityDeclaration = entityDeclarations.top();
       
  1126             entityDeclaration.notationName = symString(3);
       
  1127             if (entityDeclaration.parameter)
       
  1128                 raiseWellFormedError(QXmlStream::tr("NDATA in parameter entity declaration."));
       
  1129         }
       
  1130         //fall through
       
  1131 ./
       
  1132 
       
  1133 entity_decl ::= entity_decl_external space_opt RANGLE;
       
  1134 /.
       
  1135         case $rule_number:./
       
  1136 
       
  1137 entity_decl ::= entity_decl_start entity_value space_opt RANGLE;
       
  1138 /.
       
  1139         case $rule_number: {
       
  1140             if (referenceToUnparsedEntityDetected && !standalone) {
       
  1141                 entityDeclarations.pop();
       
  1142                 break;
       
  1143             }
       
  1144             EntityDeclaration &entityDeclaration = entityDeclarations.top();
       
  1145             if (!entityDeclaration.external)
       
  1146                 entityDeclaration.value = symString(2);
       
  1147             QString entityName = entityDeclaration.name.toString();
       
  1148             QHash<QString, Entity> &hash = entityDeclaration.parameter ? parameterEntityHash : entityHash;
       
  1149             if (!hash.contains(entityName)) {
       
  1150                 Entity entity(entityDeclaration.value.toString());
       
  1151                 entity.unparsed = (!entityDeclaration.notationName.isNull());
       
  1152                 entity.external = entityDeclaration.external;
       
  1153                 hash.insert(entityName, entity);
       
  1154             }
       
  1155         } break;
       
  1156 ./
       
  1157 
       
  1158 
       
  1159 processing_instruction ::= LANGLE QUESTIONMARK name space;
       
  1160 /.
       
  1161         case $rule_number: {
       
  1162             setType(QXmlStreamReader::ProcessingInstruction);
       
  1163             int pos = sym(4).pos + sym(4).len;
       
  1164             processingInstructionTarget = symString(3);
       
  1165             if (scanUntil("?>")) {
       
  1166                 processingInstructionData = QStringRef(&textBuffer, pos, textBuffer.size() - pos - 2);
       
  1167                 const QString piTarget(processingInstructionTarget.toString());
       
  1168                 if (!piTarget.compare(QLatin1String("xml"), Qt::CaseInsensitive)) {
       
  1169                     raiseWellFormedError(QXmlStream::tr("XML declaration not at start of document."));
       
  1170                 }
       
  1171                 else if(!QXmlUtils::isNCName(piTarget))
       
  1172                     raiseWellFormedError(QXmlStream::tr("%1 is an invalid processing instruction name.").arg(piTarget));
       
  1173             } else if (type != QXmlStreamReader::Invalid){
       
  1174                 resume($rule_number);
       
  1175                 return false;
       
  1176             }
       
  1177         } break;
       
  1178 ./
       
  1179 
       
  1180 processing_instruction ::= LANGLE QUESTIONMARK name QUESTIONMARK RANGLE;
       
  1181 /.
       
  1182         case $rule_number:
       
  1183             setType(QXmlStreamReader::ProcessingInstruction);
       
  1184             processingInstructionTarget = symString(3);
       
  1185             if (!processingInstructionTarget.toString().compare(QLatin1String("xml"), Qt::CaseInsensitive))
       
  1186                 raiseWellFormedError(QXmlStream::tr("Invalid processing instruction name."));
       
  1187         break;
       
  1188 ./
       
  1189 
       
  1190 
       
  1191 langle_bang ::= LANGLE BANG;
       
  1192 /.
       
  1193         case $rule_number:
       
  1194             if (!scanAfterLangleBang() && atEnd) {
       
  1195                 resume($rule_number);
       
  1196                 return false;
       
  1197             }
       
  1198         break;
       
  1199 ./
       
  1200 
       
  1201 comment_start ::= langle_bang DASH DASH;
       
  1202 /.
       
  1203         case $rule_number:
       
  1204             if (!scanUntil("--")) {
       
  1205                 resume($rule_number);
       
  1206                 return false;
       
  1207             }
       
  1208         break;
       
  1209 ./
       
  1210 
       
  1211 comment ::= comment_start RANGLE;
       
  1212 /.
       
  1213         case $rule_number: {
       
  1214             setType(QXmlStreamReader::Comment);
       
  1215             int pos = sym(1).pos + 4;
       
  1216             text = QStringRef(&textBuffer, pos, textBuffer.size() - pos - 3);
       
  1217         } break;
       
  1218 ./
       
  1219 
       
  1220 
       
  1221 cdata ::= langle_bang CDATA_START;
       
  1222 /.
       
  1223         case $rule_number: {
       
  1224             setType(QXmlStreamReader::Characters);
       
  1225             isCDATA = true;
       
  1226 	    isWhitespace = false;
       
  1227             int pos = sym(2).pos;
       
  1228             if (scanUntil("]]>", -1)) {
       
  1229                 text = QStringRef(&textBuffer, pos, textBuffer.size() - pos - 3);
       
  1230             } else {
       
  1231                 resume($rule_number);
       
  1232                 return false;
       
  1233             }
       
  1234         } break;
       
  1235 ./
       
  1236 
       
  1237 notation_decl_start ::= langle_bang NOTATION name space;
       
  1238 /.
       
  1239         case $rule_number: {
       
  1240             if (!scanPublicOrSystem() && atEnd) {
       
  1241                 resume($rule_number);
       
  1242                 return false;
       
  1243             }
       
  1244             NotationDeclaration &notationDeclaration = notationDeclarations.push();
       
  1245             notationDeclaration.name = symString(3);
       
  1246         } break;
       
  1247 ./
       
  1248 
       
  1249 notation_decl ::= notation_decl_start SYSTEM literal space_opt RANGLE;
       
  1250 /.
       
  1251         case $rule_number: {
       
  1252             NotationDeclaration &notationDeclaration = notationDeclarations.top();
       
  1253             notationDeclaration.systemId = symString(3);
       
  1254             notationDeclaration.publicId.clear();
       
  1255         } break;
       
  1256 ./
       
  1257 
       
  1258 notation_decl ::= notation_decl_start PUBLIC public_literal space_opt RANGLE;
       
  1259 /.
       
  1260         case $rule_number: {
       
  1261             NotationDeclaration &notationDeclaration = notationDeclarations.top();
       
  1262             notationDeclaration.systemId.clear();
       
  1263             checkPublicLiteral((notationDeclaration.publicId = symString(3)));
       
  1264         } break;
       
  1265 ./
       
  1266 
       
  1267 notation_decl ::= notation_decl_start PUBLIC public_literal space literal space_opt RANGLE;
       
  1268 /.
       
  1269         case $rule_number: {
       
  1270             NotationDeclaration &notationDeclaration = notationDeclarations.top();
       
  1271             checkPublicLiteral((notationDeclaration.publicId = symString(3)));
       
  1272             notationDeclaration.systemId = symString(5);
       
  1273         } break;
       
  1274 ./
       
  1275 
       
  1276 
       
  1277 
       
  1278 content_char ::= RANGLE | HASH | LBRACK | RBRACK | LPAREN | RPAREN | PIPE | EQ | PERCENT | SLASH | COLON | SEMICOLON | COMMA | DASH | PLUS | STAR | DOT | QUESTIONMARK | BANG | QUOTE | DBLQUOTE | LETTER | DIGIT;
       
  1279 
       
  1280 scan_content_char ::= content_char;
       
  1281 /.
       
  1282         case $rule_number:
       
  1283             isWhitespace = false;
       
  1284             // fall through
       
  1285 ./
       
  1286 
       
  1287 scan_content_char ::= SPACE;
       
  1288 /.
       
  1289         case $rule_number:
       
  1290             sym(1).len += fastScanContentCharList();
       
  1291             if (atEnd && !inParseEntity) {
       
  1292                 resume($rule_number);
       
  1293                 return false;
       
  1294             }
       
  1295 	break;
       
  1296 ./
       
  1297 
       
  1298 content_char_list ::= content_char_list char_ref;
       
  1299 content_char_list ::= content_char_list entity_ref;
       
  1300 content_char_list ::= content_char_list entity_done;
       
  1301 content_char_list ::= content_char_list scan_content_char;
       
  1302 content_char_list ::= char_ref;
       
  1303 content_char_list ::= entity_ref;
       
  1304 content_char_list ::= entity_done;
       
  1305 content_char_list ::= scan_content_char;
       
  1306 
       
  1307 
       
  1308 character_content ::= content_char_list %prec SHIFT_THERE;
       
  1309 /.
       
  1310         case $rule_number:
       
  1311 	    if (!textBuffer.isEmpty()) {
       
  1312                 setType(QXmlStreamReader::Characters);
       
  1313                 text = &textBuffer;
       
  1314 	    }
       
  1315 	break;
       
  1316 ./
       
  1317 
       
  1318 literal ::= QUOTE QUOTE;
       
  1319 /.
       
  1320         case $rule_number:./
       
  1321 literal ::= DBLQUOTE DBLQUOTE;
       
  1322 /.
       
  1323         case $rule_number:
       
  1324             clearSym();
       
  1325         break;
       
  1326 ./
       
  1327 literal ::= QUOTE literal_content_with_dblquote QUOTE;
       
  1328 /.
       
  1329         case $rule_number:./
       
  1330 literal ::= DBLQUOTE literal_content_with_quote DBLQUOTE;
       
  1331 /.
       
  1332         case $rule_number:
       
  1333             sym(1) = sym(2);
       
  1334         break;
       
  1335 ./
       
  1336 
       
  1337 literal_content_with_dblquote ::= literal_content_with_dblquote literal_content;
       
  1338 /.
       
  1339         case $rule_number:./
       
  1340 literal_content_with_quote ::= literal_content_with_quote literal_content;
       
  1341 /.
       
  1342         case $rule_number:./
       
  1343 literal_content_with_dblquote ::= literal_content_with_dblquote DBLQUOTE;
       
  1344 /.
       
  1345         case $rule_number:./
       
  1346 literal_content_with_quote ::= literal_content_with_quote QUOTE;
       
  1347 /.
       
  1348         case $rule_number:
       
  1349             sym(1).len += sym(2).len;
       
  1350         break;
       
  1351 ./
       
  1352 literal_content_with_dblquote ::= literal_content;
       
  1353 literal_content_with_quote ::= literal_content;
       
  1354 literal_content_with_dblquote ::= DBLQUOTE;
       
  1355 literal_content_with_quote ::= QUOTE;
       
  1356 
       
  1357 literal_content_start ::= LETTER | DIGIT | RANGLE | HASH | LBRACK | RBRACK | LPAREN | RPAREN | PIPE | EQ | PERCENT | SLASH | COLON | SEMICOLON | COMMA | DASH | PLUS | STAR | DOT | QUESTIONMARK | BANG;
       
  1358 
       
  1359 literal_content_start ::= SPACE;
       
  1360 /.
       
  1361         case $rule_number:
       
  1362 	    if (normalizeLiterals)
       
  1363                 textBuffer.data()[textBuffer.size()-1] = QLatin1Char(' ');
       
  1364         break;
       
  1365 ./
       
  1366 
       
  1367 literal_content ::= literal_content_start;
       
  1368 /.
       
  1369         case $rule_number:
       
  1370             sym(1).len += fastScanLiteralContent();
       
  1371             if (atEnd) {
       
  1372                 resume($rule_number);
       
  1373                 return false;
       
  1374             }
       
  1375         break;
       
  1376 ./
       
  1377 
       
  1378 
       
  1379 public_literal ::= literal;
       
  1380 /.
       
  1381         case $rule_number: {
       
  1382             if (!QXmlUtils::isPublicID(symString(1).toString())) {
       
  1383                 raiseWellFormedError(QXmlStream::tr("%1 is an invalid PUBLIC identifier.").arg(symString(1).toString()));
       
  1384                 resume($rule_number);
       
  1385                 return false;
       
  1386             }
       
  1387         } break;
       
  1388 ./
       
  1389 
       
  1390 entity_value ::= QUOTE QUOTE;
       
  1391 /.
       
  1392         case $rule_number:./
       
  1393 entity_value ::= DBLQUOTE DBLQUOTE;
       
  1394 /.
       
  1395         case $rule_number:
       
  1396             clearSym();
       
  1397         break;
       
  1398 ./
       
  1399 
       
  1400 entity_value ::= QUOTE entity_value_content_with_dblquote QUOTE;
       
  1401 /.
       
  1402         case $rule_number:./
       
  1403 entity_value ::= DBLQUOTE entity_value_content_with_quote DBLQUOTE;
       
  1404 /.
       
  1405         case $rule_number:
       
  1406 	    sym(1) = sym(2);
       
  1407         break;
       
  1408 ./
       
  1409 
       
  1410 entity_value_content_with_dblquote ::= entity_value_content_with_dblquote entity_value_content;
       
  1411 /.
       
  1412         case $rule_number:./
       
  1413 entity_value_content_with_quote ::= entity_value_content_with_quote entity_value_content;
       
  1414 /.
       
  1415         case $rule_number:./
       
  1416 entity_value_content_with_dblquote ::= entity_value_content_with_dblquote DBLQUOTE;
       
  1417 /.
       
  1418         case $rule_number:./
       
  1419 entity_value_content_with_quote ::= entity_value_content_with_quote QUOTE;
       
  1420 /.
       
  1421         case $rule_number:
       
  1422             sym(1).len += sym(2).len;
       
  1423         break;
       
  1424 ./
       
  1425 entity_value_content_with_dblquote ::= entity_value_content;
       
  1426 entity_value_content_with_quote ::= entity_value_content;
       
  1427 entity_value_content_with_dblquote ::= DBLQUOTE;
       
  1428 entity_value_content_with_quote ::= QUOTE;
       
  1429 
       
  1430 entity_value_content ::= LETTER | DIGIT | LANGLE | RANGLE | HASH | LBRACK | RBRACK | LPAREN | RPAREN | PIPE | EQ | SLASH | COLON | SEMICOLON | COMMA | SPACE | DASH | PLUS | STAR | DOT | QUESTIONMARK | BANG;
       
  1431 entity_value_content ::= char_ref | entity_ref_in_entity_value | entity_done;
       
  1432 
       
  1433 
       
  1434 attribute_value ::= QUOTE QUOTE;
       
  1435 /.
       
  1436         case $rule_number:./
       
  1437 attribute_value ::= DBLQUOTE DBLQUOTE;
       
  1438 /.
       
  1439         case $rule_number:
       
  1440             clearSym();
       
  1441         break;
       
  1442 ./
       
  1443 attribute_value ::= QUOTE attribute_value_content_with_dblquote QUOTE;
       
  1444 /.
       
  1445         case $rule_number:./
       
  1446 attribute_value ::= DBLQUOTE attribute_value_content_with_quote DBLQUOTE;
       
  1447 /.
       
  1448         case $rule_number:
       
  1449             sym(1) = sym(2);
       
  1450             lastAttributeValue = symString(1);
       
  1451         break;
       
  1452 ./
       
  1453 
       
  1454 attribute_value_content_with_dblquote ::= attribute_value_content_with_dblquote attribute_value_content;
       
  1455 /.
       
  1456         case $rule_number:./
       
  1457 attribute_value_content_with_quote ::= attribute_value_content_with_quote attribute_value_content;
       
  1458 /.
       
  1459         case $rule_number:./
       
  1460 attribute_value_content_with_dblquote ::= attribute_value_content_with_dblquote DBLQUOTE;
       
  1461 /.
       
  1462         case $rule_number:./
       
  1463 attribute_value_content_with_quote ::= attribute_value_content_with_quote QUOTE;
       
  1464 /.
       
  1465         case $rule_number:
       
  1466             sym(1).len += sym(2).len;
       
  1467         break;
       
  1468 ./
       
  1469 attribute_value_content_with_dblquote ::= attribute_value_content | DBLQUOTE;
       
  1470 attribute_value_content_with_quote ::= attribute_value_content | QUOTE;
       
  1471 
       
  1472 attribute_value_content ::= literal_content | char_ref | entity_ref_in_attribute_value | entity_done;
       
  1473 
       
  1474 attribute ::= qname space_opt EQ space_opt attribute_value;
       
  1475 /.
       
  1476         case $rule_number: {
       
  1477             QStringRef prefix = symPrefix(1);
       
  1478             if (prefix.isEmpty() && symString(1) == QLatin1String("xmlns") && namespaceProcessing) {
       
  1479                 NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
       
  1480                 namespaceDeclaration.prefix.clear();
       
  1481 
       
  1482                 const QStringRef ns(symString(5));
       
  1483                 if(ns == QLatin1String("http://www.w3.org/2000/xmlns/") ||
       
  1484                    ns == QLatin1String("http://www.w3.org/XML/1998/namespace"))
       
  1485                     raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration."));
       
  1486                 else
       
  1487                     namespaceDeclaration.namespaceUri = addToStringStorage(ns);
       
  1488             } else {
       
  1489                 Attribute &attribute = attributeStack.push();
       
  1490                 attribute.key = sym(1);
       
  1491                 attribute.value = sym(5);
       
  1492 
       
  1493                 QStringRef attributeQualifiedName = symName(1);
       
  1494                 bool normalize = false;
       
  1495                 for (int a = 0; a < dtdAttributes.size(); ++a) {
       
  1496                     DtdAttribute &dtdAttribute = dtdAttributes[a];
       
  1497                     if (!dtdAttribute.isCDATA
       
  1498                         && dtdAttribute.tagName == qualifiedName
       
  1499                         && dtdAttribute.attributeQualifiedName == attributeQualifiedName
       
  1500                         ) {
       
  1501                         normalize = true;
       
  1502                         break;
       
  1503                     }
       
  1504                 }
       
  1505                 if (normalize) {
       
  1506                     // normalize attribute value (simplify and trim)
       
  1507                     int pos = textBuffer.size();
       
  1508                     int n = 0;
       
  1509                     bool wasSpace = true;
       
  1510                     for (int i = 0; i < attribute.value.len; ++i) {
       
  1511                         QChar c = textBuffer.at(attribute.value.pos + i);
       
  1512                         if (c.unicode() == ' ') {
       
  1513                             if (wasSpace)
       
  1514                                 continue;
       
  1515                             wasSpace = true;
       
  1516                         } else {
       
  1517                             wasSpace = false;
       
  1518                         }
       
  1519                         textBuffer += textBuffer.at(attribute.value.pos + i);
       
  1520                         ++n;
       
  1521                     }
       
  1522                     if (wasSpace)
       
  1523                         while (n && textBuffer.at(pos + n - 1).unicode() == ' ')
       
  1524                             --n;
       
  1525                     attribute.value.pos = pos;
       
  1526                     attribute.value.len = n;
       
  1527                 }
       
  1528                 if (prefix == QLatin1String("xmlns") && namespaceProcessing) {
       
  1529                     NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
       
  1530                     QStringRef namespacePrefix = symString(attribute.key);
       
  1531                     QStringRef namespaceUri = symString(attribute.value);
       
  1532                     attributeStack.pop();
       
  1533                     if (((namespacePrefix == QLatin1String("xml"))
       
  1534                          ^ (namespaceUri == QLatin1String("http://www.w3.org/XML/1998/namespace")))
       
  1535                         || namespaceUri == QLatin1String("http://www.w3.org/2000/xmlns/")
       
  1536                         || namespaceUri.isEmpty()
       
  1537                         || namespacePrefix == QLatin1String("xmlns"))
       
  1538                         raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration."));
       
  1539 
       
  1540                     namespaceDeclaration.prefix = addToStringStorage(namespacePrefix);
       
  1541                     namespaceDeclaration.namespaceUri = addToStringStorage(namespaceUri);
       
  1542                 }
       
  1543             }
       
  1544         } break;
       
  1545 ./
       
  1546 
       
  1547 
       
  1548 
       
  1549 attribute_list_opt ::= | space | space attribute_list space_opt;
       
  1550 attribute_list ::= attribute | attribute_list space attribute;
       
  1551 
       
  1552 stag_start ::= LANGLE qname;
       
  1553 /.
       
  1554         case $rule_number: {
       
  1555             normalizeLiterals = true;
       
  1556             Tag &tag = tagStack_push();
       
  1557             prefix = tag.namespaceDeclaration.prefix  = addToStringStorage(symPrefix(2));
       
  1558             name = tag.name = addToStringStorage(symString(2));
       
  1559             qualifiedName = tag.qualifiedName = addToStringStorage(symName(2));
       
  1560             if ((!prefix.isEmpty() && !QXmlUtils::isNCName(prefix)) || !QXmlUtils::isNCName(name))
       
  1561                 raiseWellFormedError(QXmlStream::tr("Invalid XML name."));
       
  1562         } break;
       
  1563 ./
       
  1564 
       
  1565 
       
  1566 empty_element_tag ::= stag_start attribute_list_opt SLASH RANGLE;
       
  1567 /.
       
  1568         case $rule_number:
       
  1569             isEmptyElement = true;
       
  1570         // fall through
       
  1571 ./
       
  1572 
       
  1573 
       
  1574 stag ::= stag_start attribute_list_opt RANGLE;
       
  1575 /.
       
  1576         case $rule_number:
       
  1577             setType(QXmlStreamReader::StartElement);
       
  1578             resolveTag();
       
  1579             if (tagStack.size() == 1 && hasSeenTag && !inParseEntity)
       
  1580                 raiseWellFormedError(QXmlStream::tr("Extra content at end of document."));
       
  1581             hasSeenTag = true;
       
  1582         break;
       
  1583 ./
       
  1584 
       
  1585 
       
  1586 etag ::= LANGLE SLASH qname space_opt RANGLE;
       
  1587 /.
       
  1588         case $rule_number: {
       
  1589             setType(QXmlStreamReader::EndElement);
       
  1590             Tag &tag = tagStack_pop();
       
  1591 
       
  1592             namespaceUri = tag.namespaceDeclaration.namespaceUri;
       
  1593             name = tag.name;
       
  1594             qualifiedName = tag.qualifiedName;
       
  1595             if (qualifiedName != symName(3))
       
  1596                 raiseWellFormedError(QXmlStream::tr("Opening and ending tag mismatch."));
       
  1597         } break;
       
  1598 ./
       
  1599 
       
  1600 
       
  1601 unresolved_entity ::= UNRESOLVED_ENTITY;
       
  1602 /.
       
  1603         case $rule_number:
       
  1604             if (entitiesMustBeDeclared()) {
       
  1605                 raiseWellFormedError(QXmlStream::tr("Entity '%1' not declared.").arg(unresolvedEntity));
       
  1606                 break;
       
  1607             }
       
  1608             setType(QXmlStreamReader::EntityReference);
       
  1609             name = &unresolvedEntity;
       
  1610 	break;
       
  1611 ./
       
  1612 
       
  1613 entity_ref ::= AMPERSAND name SEMICOLON;
       
  1614 /.
       
  1615         case $rule_number: {
       
  1616             sym(1).len += sym(2).len + 1;
       
  1617             QString reference = symString(2).toString();
       
  1618             if (entityHash.contains(reference)) {
       
  1619                 Entity &entity = entityHash[reference];
       
  1620                 if (entity.unparsed) {
       
  1621                     raiseWellFormedError(QXmlStream::tr("Reference to unparsed entity '%1'.").arg(reference));
       
  1622                 } else {
       
  1623                     if (!entity.hasBeenParsed) {
       
  1624                         parseEntity(entity.value);
       
  1625                         entity.hasBeenParsed = true;
       
  1626                     }
       
  1627                     if (entity.literal)
       
  1628                         putStringLiteral(entity.value);
       
  1629                     else if (referenceEntity(entity))
       
  1630                         putReplacement(entity.value);
       
  1631                     textBuffer.chop(2 + sym(2).len);
       
  1632                     clearSym();
       
  1633                 }
       
  1634                 break;
       
  1635             }
       
  1636 
       
  1637             if (entityResolver) {
       
  1638                 QString replacementText = resolveUndeclaredEntity(reference);
       
  1639                 if (!replacementText.isNull()) {
       
  1640                     putReplacement(replacementText);
       
  1641                     textBuffer.chop(2 + sym(2).len);
       
  1642                     clearSym();
       
  1643                     break;
       
  1644                 }
       
  1645             }
       
  1646 
       
  1647 	    injectToken(UNRESOLVED_ENTITY);
       
  1648 	    unresolvedEntity = symString(2).toString();
       
  1649 	    textBuffer.chop(2 + sym(2).len);
       
  1650 	    clearSym();
       
  1651 
       
  1652         } break;
       
  1653 ./
       
  1654 
       
  1655 pereference ::= PERCENT name SEMICOLON;
       
  1656 /.
       
  1657         case $rule_number: {
       
  1658             sym(1).len += sym(2).len + 1;
       
  1659             QString reference = symString(2).toString();
       
  1660             if (parameterEntityHash.contains(reference)) {
       
  1661                 referenceToParameterEntityDetected = true;
       
  1662                 Entity &entity = parameterEntityHash[reference];
       
  1663                 if (entity.unparsed || entity.external) {
       
  1664                     referenceToUnparsedEntityDetected = true;
       
  1665                 } else {
       
  1666                     if (referenceEntity(entity))
       
  1667                         putString(entity.value);
       
  1668                     textBuffer.chop(2 + sym(2).len);
       
  1669                     clearSym();
       
  1670                 }
       
  1671             } else if (entitiesMustBeDeclared()) {
       
  1672                 raiseWellFormedError(QXmlStream::tr("Entity '%1' not declared.").arg(symString(2).toString()));
       
  1673             }
       
  1674         } break;
       
  1675 ./
       
  1676 
       
  1677 
       
  1678 
       
  1679 entity_ref_in_entity_value ::= AMPERSAND name SEMICOLON;
       
  1680 /.
       
  1681         case $rule_number:
       
  1682             sym(1).len += sym(2).len + 1;
       
  1683         break;
       
  1684 ./
       
  1685 
       
  1686 entity_ref_in_attribute_value ::= AMPERSAND name SEMICOLON;
       
  1687 /.
       
  1688         case $rule_number: {
       
  1689             sym(1).len += sym(2).len + 1;
       
  1690             QString reference = symString(2).toString();
       
  1691             if (entityHash.contains(reference)) {
       
  1692                 Entity &entity = entityHash[reference];
       
  1693                 if (entity.unparsed || entity.value.isNull()) {
       
  1694                     raiseWellFormedError(QXmlStream::tr("Reference to external entity '%1' in attribute value.").arg(reference));
       
  1695                     break;
       
  1696                 }
       
  1697                 if (!entity.hasBeenParsed) {
       
  1698                     parseEntity(entity.value);
       
  1699                     entity.hasBeenParsed = true;
       
  1700                 }
       
  1701                 if (entity.literal)
       
  1702                     putStringLiteral(entity.value);
       
  1703                 else if (referenceEntity(entity))
       
  1704                     putReplacementInAttributeValue(entity.value);
       
  1705                 textBuffer.chop(2 + sym(2).len);
       
  1706                 clearSym();
       
  1707                 break;
       
  1708             }
       
  1709 
       
  1710             if (entityResolver) {
       
  1711                 QString replacementText = resolveUndeclaredEntity(reference);
       
  1712                 if (!replacementText.isNull()) {
       
  1713                     putReplacement(replacementText);
       
  1714                     textBuffer.chop(2 + sym(2).len);
       
  1715                     clearSym();
       
  1716                     break;
       
  1717                 }
       
  1718             }
       
  1719             if (entitiesMustBeDeclared()) {
       
  1720                 raiseWellFormedError(QXmlStream::tr("Entity '%1' not declared.").arg(reference));
       
  1721             }
       
  1722         } break;
       
  1723 ./
       
  1724 
       
  1725 char_ref ::= AMPERSAND HASH char_ref_value SEMICOLON;
       
  1726 /.
       
  1727         case $rule_number: {
       
  1728             if (uint s = resolveCharRef(3)) {
       
  1729                 if (s >= 0xffff)
       
  1730                     putStringLiteral(QString::fromUcs4(&s, 1));
       
  1731                 else
       
  1732                     putChar((LETTER << 16) | s);
       
  1733 
       
  1734                 textBuffer.chop(3 + sym(3).len);
       
  1735                 clearSym();
       
  1736             } else {
       
  1737                 raiseWellFormedError(QXmlStream::tr("Invalid character reference."));
       
  1738             }
       
  1739         } break;
       
  1740 ./
       
  1741 
       
  1742 
       
  1743 char_ref_value ::= LETTER | DIGIT;
       
  1744 char_ref_value ::= char_ref_value LETTER;
       
  1745 /.
       
  1746         case $rule_number:./
       
  1747 char_ref_value ::= char_ref_value DIGIT;
       
  1748 /.
       
  1749         case $rule_number:
       
  1750             sym(1).len += sym(2).len;
       
  1751         break;
       
  1752 ./
       
  1753 
       
  1754 
       
  1755 content ::= content character_content;
       
  1756 content ::= content stag content etag;
       
  1757 content ::= content empty_element_tag;
       
  1758 content ::= content comment;
       
  1759 content ::= content cdata;
       
  1760 content ::= content xml_decl;
       
  1761 content ::= content processing_instruction;
       
  1762 content ::= content doctype_decl;
       
  1763 content ::= content unresolved_entity;
       
  1764 content ::=  ;
       
  1765 
       
  1766 
       
  1767 space ::=  SPACE;
       
  1768 /.
       
  1769         case $rule_number:
       
  1770             sym(1).len += fastScanSpace();
       
  1771             if (atEnd) {
       
  1772                 resume($rule_number);
       
  1773                 return false;
       
  1774             }
       
  1775         break;
       
  1776 ./
       
  1777 
       
  1778 
       
  1779 space_opt ::=;
       
  1780 space_opt ::= space;
       
  1781 
       
  1782 qname ::= LETTER;
       
  1783 /.
       
  1784         case $rule_number: {
       
  1785             sym(1).len += fastScanName(&sym(1).prefix);
       
  1786             if (atEnd) {
       
  1787                 resume($rule_number);
       
  1788                 return false;
       
  1789             }
       
  1790         } break;
       
  1791 ./
       
  1792 
       
  1793 name ::= LETTER;
       
  1794 /.
       
  1795         case $rule_number:
       
  1796             sym(1).len += fastScanName();
       
  1797             if (atEnd) {
       
  1798                 resume($rule_number);
       
  1799                 return false;
       
  1800             }
       
  1801         break;
       
  1802 ./
       
  1803 
       
  1804 nmtoken ::= LETTER;
       
  1805 /.
       
  1806         case $rule_number:./
       
  1807 nmtoken ::= DIGIT;
       
  1808 /.
       
  1809         case $rule_number:./
       
  1810 nmtoken ::= DOT;
       
  1811 /.
       
  1812         case $rule_number:./
       
  1813 nmtoken ::= DASH;
       
  1814 /.
       
  1815         case $rule_number:./
       
  1816 nmtoken ::= COLON;
       
  1817 /.
       
  1818         case $rule_number:
       
  1819             sym(1).len += fastScanNMTOKEN();
       
  1820             if (atEnd) {
       
  1821                 resume($rule_number);
       
  1822                 return false;
       
  1823             }
       
  1824 
       
  1825         break;
       
  1826 ./
       
  1827 
       
  1828 
       
  1829 /.
       
  1830     default:
       
  1831         ;
       
  1832     } // switch
       
  1833             act = state_stack[tos] = nt_action (act, lhs[r] - TERMINAL_COUNT);
       
  1834             if (type != QXmlStreamReader::NoToken)
       
  1835                 return true;
       
  1836         } else {
       
  1837             parseError();
       
  1838             break;
       
  1839         }
       
  1840     }
       
  1841     return false;
       
  1842 }
       
  1843 ./