GetTokenCount() private method

private GetTokenCount ( ) : int
return int
        internal void GetTokens(TokenizerStream stream, int maxNum, bool endAfterKet)
        {
            while (maxNum == -1 || stream.GetTokenCount() < maxNum)
            {
                int  i = -1;
                byte ch;
                int  cb             = 0;
                bool inLiteral      = false;
                bool inQuotedString = false;

                StringMaker m = _maker;

                m._outStringBuilder = null;
                m._outIndex         = 0;

BEGINNING:

                if (_inSavedCharacter != -1)
                {
                    i = _inSavedCharacter;
                    _inSavedCharacter = -1;
                }
                else
                {
                    switch (_inTokenSource)
                    {
                    case TokenSource.UnicodeByteArray:
                        if (_inIndex + 1 >= _inSize)
                        {
                            stream.AddToken(-1);
                            return;
                        }

                        i         = (int)((_inBytes[_inIndex + 1] << 8) + _inBytes[_inIndex]);
                        _inIndex += 2;
                        break;

                    case TokenSource.UTF8ByteArray:
                        if (_inIndex >= _inSize)
                        {
                            stream.AddToken(-1);
                            return;
                        }

                        i = (int)(_inBytes[_inIndex++]);

                        // single byte -- case, early out as we're done already
                        if ((i & 0x80) == 0x00)
                        {
                            break;
                        }

                        // to decode the lead byte switch on the high nibble
                        // shifted down so the switch gets dense integers
                        switch ((i & 0xf0) >> 4)
                        {
                        case 0x8: // 1000  (together these 4 make 10xxxxx)
                        case 0x9: // 1001
                        case 0xa: // 1010
                        case 0xb: // 1011
                            // trail byte is an error
                            throw new XmlSyntaxException(LineNo);

                        case 0xc: // 1100  (these two make 110xxxxx)
                        case 0xd: // 1101
                            // two byte encoding (1 trail byte)
                            i &= 0x1f;
                            cb = 2;
                            break;

                        case 0xe: // 1110 (this gets us 1110xxxx)
                            // three byte encoding (2 trail bytes)
                            i &= 0x0f;
                            cb = 3;
                            break;

                        case 0xf: // 1111 (and finally 1111xxxx)
                            // 4 byte encoding is an error
                            throw new XmlSyntaxException(LineNo);
                        }

                        // at least one trail byte, fetch it
                        if (_inIndex >= _inSize)
                        {
                            throw new XmlSyntaxException(LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                        }

                        ch = _inBytes[_inIndex++];

                        // must be trail byte encoding
                        if ((ch & 0xc0) != 0x80)
                        {
                            throw new XmlSyntaxException(LineNo);
                        }

                        i = (i << 6) | (ch & 0x3f);

                        // done now if 2 byte encoding, otherwise go for 3
                        if (cb == 2)
                        {
                            break;
                        }

                        if (_inIndex >= _inSize)
                        {
                            throw new XmlSyntaxException(LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                        }

                        ch = _inBytes[_inIndex++];

                        // must be trail byte encoding
                        if ((ch & 0xc0) != 0x80)
                        {
                            throw new XmlSyntaxException(LineNo);
                        }

                        i = (i << 6) | (ch & 0x3f);
                        break;

                    case TokenSource.ASCIIByteArray:
                        if (_inIndex >= _inSize)
                        {
                            stream.AddToken(-1);
                            return;
                        }

                        i = (int)(_inBytes[_inIndex++]);
                        break;

                    case TokenSource.CharArray:
                        if (_inIndex >= _inSize)
                        {
                            stream.AddToken(-1);
                            return;
                        }

                        i = (int)(_inChars[_inIndex++]);
                        break;

                    case TokenSource.String:
                        if (_inIndex >= _inSize)
                        {
                            stream.AddToken(-1);
                            return;
                        }

                        i = (int)(_inString[_inIndex++]);
                        break;

                    case TokenSource.NestedStrings:
                        if (_inNestedSize != 0)
                        {
                            if (_inNestedIndex < _inNestedSize)
                            {
                                i = _inNestedString[_inNestedIndex++];
                                break;
                            }

                            _inNestedSize = 0;
                        }

                        if (_inIndex >= _inSize)
                        {
                            stream.AddToken(-1);
                            return;
                        }

                        i = (int)(_inString[_inIndex++]);

                        if (i != '{')
                        {
                            break;
                        }

                        for (int istr = 0; istr < _searchStrings.Length; istr++)
                        {
                            if (0 == String.Compare(_searchStrings[istr], 0, _inString, _inIndex - 1, _searchStrings[istr].Length, StringComparison.Ordinal))
                            {
                                _inNestedString = _replaceStrings[istr];
                                _inNestedSize   = _inNestedString.Length;
                                _inNestedIndex  = 1;
                                i         = _inNestedString[0];
                                _inIndex += _searchStrings[istr].Length - 1;
                                break;
                            }
                        }

                        break;

                    default:
                        i = _inTokenReader.Read();
                        if (i == -1)
                        {
                            stream.AddToken(-1);
                            return;
                        }
                        break;
                    }
                }

                if (!inLiteral)
                {
                    switch (i)
                    {
                    // skip whitespace
                    case intSpace:
                    case intTab:
                    case intCR:
                        goto BEGINNING;

                    // count linefeeds
                    case intLF:
                        LineNo++;
                        goto BEGINNING;

                    case intOpenBracket:
                        _inProcessingTag++;
                        stream.AddToken(bra);
                        continue;

                    case intCloseBracket:
                        _inProcessingTag--;
                        stream.AddToken(ket);
                        if (endAfterKet)
                        {
                            return;
                        }
                        continue;

                    case intEquals:
                        stream.AddToken(equals);
                        continue;

                    case intSlash:
                        if (_inProcessingTag != 0)
                        {
                            stream.AddToken(slash);
                            continue;
                        }
                        break;

                    case intQuest:
                        if (_inProcessingTag != 0)
                        {
                            stream.AddToken(quest);
                            continue;
                        }
                        break;

                    case intBang:
                        if (_inProcessingTag != 0)
                        {
                            stream.AddToken(bang);
                            continue;
                        }
                        break;

                    case intDash:
                        if (_inProcessingTag != 0)
                        {
                            stream.AddToken(dash);
                            continue;
                        }
                        break;

                    case intQuote:
                        inLiteral      = true;
                        inQuotedString = true;
                        goto BEGINNING;
                    }
                }
                else
                {
                    switch (i)
                    {
                    case intOpenBracket:
                        if (!inQuotedString)
                        {
                            _inSavedCharacter = i;
                            stream.AddToken(cstr);
                            stream.AddString(this.GetStringToken());
                            continue;
                        }
                        break;

                    case intCloseBracket:
                    case intEquals:
                    case intSlash:
                        if (!inQuotedString && _inProcessingTag != 0)
                        {
                            _inSavedCharacter = i;
                            stream.AddToken(cstr);
                            stream.AddString(this.GetStringToken());
                            continue;
                        }
                        break;

                    case intQuote:
                        if (inQuotedString)
                        {
                            stream.AddToken(cstr);
                            stream.AddString(this.GetStringToken());
                            continue;
                        }
                        break;

                    case intTab:
                    case intCR:
                    case intSpace:
                        if (!inQuotedString)
                        {
                            stream.AddToken(cstr);
                            stream.AddString(this.GetStringToken());
                            continue;
                        }
                        break;

                    // count linefeeds
                    case intLF:
                        LineNo++;

                        if (!inQuotedString)
                        {
                            stream.AddToken(cstr);
                            stream.AddString(this.GetStringToken());
                            continue;
                        }
                        break;
                    }
                }

                inLiteral = true;

                // add character  to the string
                if (m._outIndex < StringMaker.outMaxSize)
                {
                    // easy case
                    m._outChars[m._outIndex++] = (char)i;
                }
                else
                {
                    if (m._outStringBuilder == null)
                    {
                        // OK, first check if we have to init the StringBuilder
                        m._outStringBuilder = new StringBuilder();
                    }

                    // OK, copy from _outChars to _outStringBuilder
                    m._outStringBuilder.Append(m._outChars, 0, StringMaker.outMaxSize);

                    // reset _outChars pointer
                    m._outChars[0] = (char)i;
                    m._outIndex    = 1;
                }

                goto BEGINNING;
            }
        }
Beispiel #2
0
        internal void GetTokens( TokenizerStream stream, int maxNum, bool endAfterKet )
        {
            while (maxNum == -1 || stream.GetTokenCount() < maxNum)
            {
                int i = -1;
                byte ch;
                int cb = 0;
                bool inLiteral = false;
                bool inQuotedString = false;
            
                StringMaker m = _maker;
            
                m._outStringBuilder = null;
                m._outIndex = 0;
                        
            BEGINNING: 
            
                if (_inSavedCharacter != -1)
                {
                       i = _inSavedCharacter;
                       _inSavedCharacter = -1;
                }
                else switch (_inTokenSource)
                {
                case TokenSource.UnicodeByteArray:
                    if (_inIndex + 1 >= _inSize)
                    {
                        stream.AddToken( -1 );
                        return;
                    }

                     i = (int)((_inBytes[_inIndex+1]<<8) + _inBytes[_inIndex]);
                      _inIndex += 2;      
                    break;
                
                 case TokenSource.UTF8ByteArray:
                    if (_inIndex >= _inSize)
                    {
                        stream.AddToken( -1 );
                        return;
                    }

                    i = (int)(_inBytes[_inIndex++]);

                    // single byte -- case, early out as we're done already
                    if ((i & 0x80) == 0x00)
                        break;

                    // to decode the lead byte switch on the high nibble 
                    // shifted down so the switch gets dense integers
                    switch ((i & 0xf0) >>4)
                    {
                    case 0x8:   // 1000  (together these 4 make 10xxxxx)
                    case 0x9:   // 1001
                    case 0xa:   // 1010
                    case 0xb:   // 1011
                        // trail byte is an error
                        throw new XmlSyntaxException( LineNo );

                    case 0xc:   // 1100  (these two make 110xxxxx)
                    case 0xd:   // 1101
                        // two byte encoding (1 trail byte)
                        i &= 0x1f;
                        cb = 2;
                        break;

                    case 0xe:   // 1110 (this gets us 1110xxxx)
                        // three byte encoding (2 trail bytes)
                        i &= 0x0f;
                        cb = 3;
                        break;

                    case 0xf:   // 1111 (and finally 1111xxxx)
                        // 4 byte encoding is an error
                        throw new XmlSyntaxException( LineNo );
                    }

                    // at least one trail byte, fetch it
                    if (_inIndex >= _inSize)
                        throw new XmlSyntaxException (LineNo, Environment.GetResourceString( "XMLSyntax_UnexpectedEndOfFile" ));

                    ch = _inBytes[_inIndex++];

                    // must be trail byte encoding
                    if ((ch & 0xc0) != 0x80)
                        throw new XmlSyntaxException( LineNo );

                    i = (i<<6) | (ch & 0x3f);

                    // done now if 2 byte encoding, otherwise go for 3
                    if (cb == 2)
                        break;

                    if (_inIndex >= _inSize)
                        throw new XmlSyntaxException (LineNo, Environment.GetResourceString( "XMLSyntax_UnexpectedEndOfFile" ));

                    ch = _inBytes[_inIndex++];

                    // must be trail byte encoding
                    if ((ch & 0xc0) != 0x80)
                        throw new XmlSyntaxException( LineNo );

                    i = (i<<6) | (ch & 0x3f);
                    break;                
                
                case TokenSource.ASCIIByteArray:
                    if (_inIndex >= _inSize)
                    {
                        stream.AddToken( -1 );
                        return;
                    }

                    i = (int)(_inBytes[_inIndex++]);
                    break;

                case TokenSource.CharArray:
                    if (_inIndex >= _inSize)
                    {
                        stream.AddToken( -1 );
                        return;
                    }

                     i = (int)(_inChars[_inIndex++]);
                    break;
                
                case TokenSource.String:
                    if (_inIndex >= _inSize)
                    {
                        stream.AddToken( -1 );
                        return;
                    }

                    i = (int)(_inString[_inIndex++]);
                    break;
                            
                case TokenSource.NestedStrings:
                    if (_inNestedSize != 0)
                    {
                        if (_inNestedIndex < _inNestedSize)
                        {
                            i = _inNestedString[_inNestedIndex++];
                            break;
                        }
                    
                        _inNestedSize = 0;
                    }
                
                    if (_inIndex >= _inSize)
                    {
                        stream.AddToken( -1 );
                        return;
                    }

                    i = (int)(_inString[_inIndex++]);
                
                    if (i != '{')
                        break;
                                    
                    for (int istr=0; istr < _searchStrings.Length; istr++)
                    {
                        if (0==String.Compare(_searchStrings[istr], 0, _inString, _inIndex-1, _searchStrings[istr].Length, StringComparison.Ordinal))
                        {
                            _inNestedString = _replaceStrings[istr];
                            _inNestedSize = _inNestedString.Length;
                            _inNestedIndex = 1;
                            i = _inNestedString[0];
                            _inIndex += _searchStrings[istr].Length - 1;   
                            break;
                        }
                    }
                
                    break;
                    
                default:
                    i = _inTokenReader.Read();
                    if (i == -1) 
                    {
                        stream.AddToken( -1 );
                        return;
                    }
                    break;
                }

                if (!inLiteral)
                {
                    switch (i)
                    {
                    // skip whitespace
                    case intSpace:
                    case intTab:
                    case intCR:
                        goto BEGINNING;

                    // count linefeeds
                    case intLF:
                        LineNo++;
                        goto BEGINNING;
                                        
                    case intOpenBracket:
                        _inProcessingTag++;
                        stream.AddToken( bra );
                        continue;
                    
                    case intCloseBracket:
                        _inProcessingTag--;
                        stream.AddToken( ket );
                        if (endAfterKet)
                            return;
                        continue;
                    
                    case intEquals:
                        stream.AddToken( equals );
                        continue;
                    
                    case intSlash:
                        if (_inProcessingTag != 0)
                        {
                            stream.AddToken( slash );
                            continue;
                        }
                        break;

                    case intQuest:
                        if (_inProcessingTag != 0)
                        {
                            stream.AddToken( quest );
                            continue;
                        } 
                        break;

                    case intBang:
                        if (_inProcessingTag != 0)
                        {
                            stream.AddToken( bang );
                            continue;
                        } 
                        break;

                    case intDash:
                        if (_inProcessingTag != 0) 
                        {
                            stream.AddToken( dash );
                            continue;
                        }
                        break;

                    case intQuote:
                        inLiteral = true;
                        inQuotedString = true;
                        goto BEGINNING;
                    }
                }
                else
                   {
                    switch (i)
                    {
                    case intOpenBracket:
                        if (!inQuotedString)
                        {
                            _inSavedCharacter = i;
                            stream.AddToken( cstr );
                            stream.AddString( this.GetStringToken() );
                            continue;
                        }
                        break;
                        
                    case intCloseBracket:
                    case intEquals:
                    case intSlash:
                        if (!inQuotedString && _inProcessingTag != 0)
                        {
                            _inSavedCharacter = i;
                            stream.AddToken( cstr );
                            stream.AddString( this.GetStringToken() );
                            continue;
                        }
                        break;
                    
                    case intQuote:
                        if (inQuotedString)
                        {
                            stream.AddToken( cstr );
                            stream.AddString( this.GetStringToken() );
                            continue;
                        }
                        break;
                    
                    case intTab:
                    case intCR:
                    case intSpace:
                        if (!inQuotedString)
                        {
                            stream.AddToken( cstr );
                            stream.AddString( this.GetStringToken() );
                            continue;
                        }
                        break;

                    // count linefeeds
                    case intLF:
                        LineNo++;

                        if (!inQuotedString)
                        {
                            stream.AddToken( cstr );
                            stream.AddString( this.GetStringToken() );
                            continue;
                        }
                        break;                        
                    }
                }

                inLiteral = true;
                                       
                // add character  to the string
                if (m._outIndex < StringMaker.outMaxSize) 
                {
                    // easy case
                    m._outChars[m._outIndex++] = (char)i;
                } 
                else
                {
                    if (m._outStringBuilder == null) 
                    {
                       // OK, first check if we have to init the StringBuilder
                        m._outStringBuilder = new StringBuilder();
                    }
                
                    // OK, copy from _outChars to _outStringBuilder
                    m._outStringBuilder.Append(m._outChars, 0, StringMaker.outMaxSize);
                
                    // reset _outChars pointer
                    m._outChars[0] = (char)i;
                    m._outIndex = 1;
                }
                        
                goto BEGINNING;
            }
        }
Beispiel #3
0
        internal void GetTokens(TokenizerStream stream, int maxNum, bool endAfterKet)
        {
            while (maxNum == -1 || stream.GetTokenCount() < maxNum)
            {
                int  num1  = 0;
                bool flag1 = false;
                bool flag2 = false;
                Tokenizer.StringMaker stringMaker1 = this._maker;
                stringMaker1._outStringBuilder = (StringBuilder)null;
                stringMaker1._outIndex         = 0;
                int num2;
                while (true)
                {
                    if (this._inSavedCharacter != -1)
                    {
                        num2 = this._inSavedCharacter;
                        this._inSavedCharacter = -1;
                    }
                    else
                    {
                        switch (this._inTokenSource)
                        {
                        case Tokenizer.TokenSource.UnicodeByteArray:
                            if (this._inIndex + 1 < this._inSize)
                            {
                                num2          = ((int)this._inBytes[this._inIndex + 1] << 8) + (int)this._inBytes[this._inIndex];
                                this._inIndex = this._inIndex + 2;
                                break;
                            }
                            goto label_6;

                        case Tokenizer.TokenSource.UTF8ByteArray:
                            if (this._inIndex < this._inSize)
                            {
                                byte[] numArray1 = this._inBytes;
                                int    num3      = this._inIndex;
                                this._inIndex = num3 + 1;
                                int index1 = num3;
                                num2 = (int)numArray1[index1];
                                if ((num2 & 128) != 0)
                                {
                                    switch ((num2 & 240) >> 4)
                                    {
                                    case 8:
                                    case 9:
                                    case 10:
                                    case 11:
                                        goto label_12;

                                    case 12:
                                    case 13:
                                        num2 &= 31;
                                        num1  = 2;
                                        break;

                                    case 14:
                                        num2 &= 15;
                                        num1  = 3;
                                        break;

                                    case 15:
                                        goto label_15;
                                    }
                                    if (this._inIndex < this._inSize)
                                    {
                                        byte[] numArray2 = this._inBytes;
                                        int    num4      = this._inIndex;
                                        this._inIndex = num4 + 1;
                                        int  index2 = num4;
                                        byte num5   = numArray2[index2];
                                        if (((int)num5 & 192) == 128)
                                        {
                                            num2 = num2 << 6 | (int)num5 & 63;
                                            if (num1 != 2)
                                            {
                                                if (this._inIndex < this._inSize)
                                                {
                                                    byte[] numArray3 = this._inBytes;
                                                    int    num6      = this._inIndex;
                                                    this._inIndex = num6 + 1;
                                                    int  index3 = num6;
                                                    byte num7   = numArray3[index3];
                                                    if (((int)num7 & 192) == 128)
                                                    {
                                                        num2 = num2 << 6 | (int)num7 & 63;
                                                        break;
                                                    }
                                                    goto label_24;
                                                }
                                                else
                                                {
                                                    goto label_22;
                                                }
                                            }
                                            else
                                            {
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            goto label_19;
                                        }
                                    }
                                    else
                                    {
                                        goto label_17;
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                goto label_9;
                            }

                        case Tokenizer.TokenSource.ASCIIByteArray:
                            if (this._inIndex < this._inSize)
                            {
                                byte[] numArray = this._inBytes;
                                int    num3     = this._inIndex;
                                this._inIndex = num3 + 1;
                                int index = num3;
                                num2 = (int)numArray[index];
                                break;
                            }
                            goto label_27;

                        case Tokenizer.TokenSource.CharArray:
                            if (this._inIndex < this._inSize)
                            {
                                char[] chArray = this._inChars;
                                int    num3    = this._inIndex;
                                this._inIndex = num3 + 1;
                                int index = num3;
                                num2 = (int)chArray[index];
                                break;
                            }
                            goto label_30;

                        case Tokenizer.TokenSource.String:
                            if (this._inIndex < this._inSize)
                            {
                                string str  = this._inString;
                                int    num3 = this._inIndex;
                                this._inIndex = num3 + 1;
                                int index = num3;
                                num2 = (int)str[index];
                                break;
                            }
                            goto label_33;

                        case Tokenizer.TokenSource.NestedStrings:
                            if (this._inNestedSize != 0)
                            {
                                if (this._inNestedIndex < this._inNestedSize)
                                {
                                    string str  = this._inNestedString;
                                    int    num3 = this._inNestedIndex;
                                    this._inNestedIndex = num3 + 1;
                                    int index = num3;
                                    num2 = (int)str[index];
                                    break;
                                }
                                this._inNestedSize = 0;
                            }
                            if (this._inIndex < this._inSize)
                            {
                                string str  = this._inString;
                                int    num3 = this._inIndex;
                                this._inIndex = num3 + 1;
                                int index1 = num3;
                                num2 = (int)str[index1];
                                if (num2 == 123)
                                {
                                    for (int index2 = 0; index2 < this._searchStrings.Length; ++index2)
                                    {
                                        if (string.Compare(this._searchStrings[index2], 0, this._inString, this._inIndex - 1, this._searchStrings[index2].Length, StringComparison.Ordinal) == 0)
                                        {
                                            this._inNestedString = this._replaceStrings[index2];
                                            this._inNestedSize   = this._inNestedString.Length;
                                            this._inNestedIndex  = 1;
                                            num2          = (int)this._inNestedString[0];
                                            this._inIndex = this._inIndex + (this._searchStrings[index2].Length - 1);
                                            break;
                                        }
                                    }
                                    break;
                                }
                                break;
                            }
                            goto label_40;

                        default:
                            num2 = this._inTokenReader.Read();
                            if (num2 != -1)
                            {
                                break;
                            }
                            goto label_48;
                        }
                    }
                    if (!flag1)
                    {
                        switch (num2)
                        {
                        case 45:
                            if (this._inProcessingTag == 0)
                            {
                                break;
                            }
                            goto label_63;

                        case 47:
                            if (this._inProcessingTag == 0)
                            {
                                break;
                            }
                            goto label_57;

                        case 60:
                            goto label_52;

                        case 61:
                            goto label_55;

                        case 62:
                            goto label_53;

                        case 63:
                            if (this._inProcessingTag == 0)
                            {
                                break;
                            }
                            goto label_59;

                        case 9:
                        case 13:
                        case 32:
                            continue;

                        case 10:
                            this.LineNo = this.LineNo + 1;
                            continue;

                        case 33:
                            if (this._inProcessingTag == 0)
                            {
                                break;
                            }
                            goto label_61;

                        case 34:
                            flag1 = true;
                            flag2 = true;
                            continue;
                        }
                    }
                    else
                    {
                        switch (num2)
                        {
                        case 34:
                            if (!flag2)
                            {
                                break;
                            }
                            goto label_72;

                        case 47:
                        case 61:
                        case 62:
                            if (flag2 || this._inProcessingTag == 0)
                            {
                                break;
                            }
                            goto label_70;

                        case 60:
                            if (flag2)
                            {
                                break;
                            }
                            goto label_68;

                        case 9:
                        case 13:
                        case 32:
                            if (flag2)
                            {
                                break;
                            }
                            goto label_74;

                        case 10:
                            this.LineNo = this.LineNo + 1;
                            if (flag2)
                            {
                                break;
                            }
                            goto label_76;
                        }
                    }
                    flag1 = true;
                    if (stringMaker1._outIndex < 512)
                    {
                        char[] chArray = stringMaker1._outChars;
                        Tokenizer.StringMaker stringMaker2 = stringMaker1;
                        int num3 = stringMaker2._outIndex;
                        int num4 = num3 + 1;
                        stringMaker2._outIndex = num4;
                        int index = num3;
                        int num5  = (int)(ushort)num2;
                        chArray[index] = (char)num5;
                    }
                    else
                    {
                        if (stringMaker1._outStringBuilder == null)
                        {
                            stringMaker1._outStringBuilder = new StringBuilder();
                        }
                        stringMaker1._outStringBuilder.Append(stringMaker1._outChars, 0, 512);
                        stringMaker1._outChars[0] = (char)num2;
                        stringMaker1._outIndex    = 1;
                    }
                }
label_6:
                stream.AddToken((short)-1);
                break;
label_9:
                stream.AddToken((short)-1);
                break;
label_12:
                throw new XmlSyntaxException(this.LineNo);
label_15:
                throw new XmlSyntaxException(this.LineNo);
label_17:
                throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
label_19:
                throw new XmlSyntaxException(this.LineNo);
label_22:
                throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
label_24:
                throw new XmlSyntaxException(this.LineNo);
label_27:
                stream.AddToken((short)-1);
                break;
label_30:
                stream.AddToken((short)-1);
                break;
label_33:
                stream.AddToken((short)-1);
                break;
label_40:
                stream.AddToken((short)-1);
                break;
label_48:
                stream.AddToken((short)-1);
                break;
label_52:
                this._inProcessingTag = this._inProcessingTag + 1;
                stream.AddToken((short)0);
                continue;
label_53:
                this._inProcessingTag = this._inProcessingTag - 1;
                stream.AddToken((short)1);
                if (endAfterKet)
                {
                    break;
                }
                continue;
label_55:
                stream.AddToken((short)4);
                continue;
label_57:
                stream.AddToken((short)2);
                continue;
label_59:
                stream.AddToken((short)5);
                continue;
label_61:
                stream.AddToken((short)6);
                continue;
label_63:
                stream.AddToken((short)7);
                continue;
label_68:
                this._inSavedCharacter = num2;
                stream.AddToken((short)3);
                stream.AddString(this.GetStringToken());
                continue;
label_70:
                this._inSavedCharacter = num2;
                stream.AddToken((short)3);
                stream.AddString(this.GetStringToken());
                continue;
label_72:
                stream.AddToken((short)3);
                stream.AddString(this.GetStringToken());
                continue;
label_74:
                stream.AddToken((short)3);
                stream.AddString(this.GetStringToken());
                continue;
label_76:
                stream.AddToken((short)3);
                stream.AddString(this.GetStringToken());
            }
        }
        // Token: 0x06002BA9 RID: 11177 RVA: 0x000A3D34 File Offset: 0x000A1F34
        internal void GetTokens(TokenizerStream stream, int maxNum, bool endAfterKet)
        {
            while (maxNum == -1 || stream.GetTokenCount() < maxNum)
            {
                int  num   = 0;
                bool flag  = false;
                bool flag2 = false;
                Tokenizer.StringMaker maker = this._maker;
                maker._outStringBuilder = null;
                maker._outIndex         = 0;
                int num2;
                for (;;)
                {
                    if (this._inSavedCharacter != -1)
                    {
                        num2 = this._inSavedCharacter;
                        this._inSavedCharacter = -1;
                    }
                    else
                    {
                        switch (this._inTokenSource)
                        {
                        case Tokenizer.TokenSource.UnicodeByteArray:
                            if (this._inIndex + 1 >= this._inSize)
                            {
                                goto Block_3;
                            }
                            num2           = ((int)this._inBytes[this._inIndex + 1] << 8) + (int)this._inBytes[this._inIndex];
                            this._inIndex += 2;
                            break;

                        case Tokenizer.TokenSource.UTF8ByteArray:
                        {
                            if (this._inIndex >= this._inSize)
                            {
                                goto Block_4;
                            }
                            byte[] inBytes = this._inBytes;
                            int    num3    = this._inIndex;
                            this._inIndex = num3 + 1;
                            num2          = inBytes[num3];
                            if ((num2 & 128) != 0)
                            {
                                switch ((num2 & 240) >> 4)
                                {
                                case 8:
                                case 9:
                                case 10:
                                case 11:
                                    goto IL_12D;

                                case 12:
                                case 13:
                                    num2 &= 31;
                                    num   = 2;
                                    break;

                                case 14:
                                    num2 &= 15;
                                    num   = 3;
                                    break;

                                case 15:
                                    goto IL_14B;
                                }
                                if (this._inIndex >= this._inSize)
                                {
                                    goto Block_7;
                                }
                                byte[] inBytes2 = this._inBytes;
                                num3          = this._inIndex;
                                this._inIndex = num3 + 1;
                                byte b = inBytes2[num3];
                                if ((b & 192) != 128)
                                {
                                    goto Block_8;
                                }
                                num2 = (num2 << 6 | (int)(b & 63));
                                if (num != 2)
                                {
                                    if (this._inIndex >= this._inSize)
                                    {
                                        goto Block_10;
                                    }
                                    byte[] inBytes3 = this._inBytes;
                                    num3          = this._inIndex;
                                    this._inIndex = num3 + 1;
                                    b             = inBytes3[num3];
                                    if ((b & 192) != 128)
                                    {
                                        goto Block_11;
                                    }
                                    num2 = (num2 << 6 | (int)(b & 63));
                                }
                            }
                            break;
                        }

                        case Tokenizer.TokenSource.ASCIIByteArray:
                        {
                            if (this._inIndex >= this._inSize)
                            {
                                goto Block_12;
                            }
                            byte[] inBytes4 = this._inBytes;
                            int    num3     = this._inIndex;
                            this._inIndex = num3 + 1;
                            num2          = inBytes4[num3];
                            break;
                        }

                        case Tokenizer.TokenSource.CharArray:
                        {
                            if (this._inIndex >= this._inSize)
                            {
                                goto Block_13;
                            }
                            char[] inChars = this._inChars;
                            int    num3    = this._inIndex;
                            this._inIndex = num3 + 1;
                            num2          = inChars[num3];
                            break;
                        }

                        case Tokenizer.TokenSource.String:
                        {
                            if (this._inIndex >= this._inSize)
                            {
                                goto Block_14;
                            }
                            string inString = this._inString;
                            int    num3     = this._inIndex;
                            this._inIndex = num3 + 1;
                            num2          = (int)inString[num3];
                            break;
                        }

                        case Tokenizer.TokenSource.NestedStrings:
                        {
                            int num3;
                            if (this._inNestedSize != 0)
                            {
                                if (this._inNestedIndex < this._inNestedSize)
                                {
                                    string inNestedString = this._inNestedString;
                                    num3 = this._inNestedIndex;
                                    this._inNestedIndex = num3 + 1;
                                    num2 = (int)inNestedString[num3];
                                    break;
                                }
                                this._inNestedSize = 0;
                            }
                            if (this._inIndex >= this._inSize)
                            {
                                goto Block_17;
                            }
                            string inString2 = this._inString;
                            num3          = this._inIndex;
                            this._inIndex = num3 + 1;
                            num2          = (int)inString2[num3];
                            if (num2 == 123)
                            {
                                for (int i = 0; i < this._searchStrings.Length; i++)
                                {
                                    if (string.Compare(this._searchStrings[i], 0, this._inString, this._inIndex - 1, this._searchStrings[i].Length, StringComparison.Ordinal) == 0)
                                    {
                                        this._inNestedString = this._replaceStrings[i];
                                        this._inNestedSize   = this._inNestedString.Length;
                                        this._inNestedIndex  = 1;
                                        num2           = (int)this._inNestedString[0];
                                        this._inIndex += this._searchStrings[i].Length - 1;
                                        break;
                                    }
                                }
                            }
                            break;
                        }

                        default:
                            num2 = this._inTokenReader.Read();
                            if (num2 == -1)
                            {
                                goto Block_21;
                            }
                            break;
                        }
                    }
                    if (!flag)
                    {
                        if (num2 <= 34)
                        {
                            switch (num2)
                            {
                            case 9:
                            case 13:
                                continue;

                            case 10:
                                this.LineNo++;
                                continue;

                            case 11:
                            case 12:
                                break;

                            default:
                                switch (num2)
                                {
                                case 32:
                                    continue;

                                case 33:
                                    if (this._inProcessingTag != 0)
                                    {
                                        goto Block_32;
                                    }
                                    break;

                                case 34:
                                    flag  = true;
                                    flag2 = true;
                                    continue;
                                }
                                break;
                            }
                        }
                        else if (num2 != 45)
                        {
                            if (num2 != 47)
                            {
                                switch (num2)
                                {
                                case 60:
                                    goto IL_48A;

                                case 61:
                                    goto IL_4C0;

                                case 62:
                                    goto IL_4A4;

                                case 63:
                                    if (this._inProcessingTag != 0)
                                    {
                                        goto Block_31;
                                    }
                                    break;
                                }
                            }
                            else if (this._inProcessingTag != 0)
                            {
                                goto Block_30;
                            }
                        }
                        else if (this._inProcessingTag != 0)
                        {
                            goto Block_33;
                        }
                    }
                    else if (num2 <= 34)
                    {
                        switch (num2)
                        {
                        case 9:
                        case 13:
                            break;

                        case 10:
                            this.LineNo++;
                            if (!flag2)
                            {
                                goto Block_46;
                            }
                            goto IL_62F;

                        case 11:
                        case 12:
                            goto IL_62F;

                        default:
                            if (num2 != 32)
                            {
                                if (num2 != 34)
                                {
                                    goto IL_62F;
                                }
                                if (flag2)
                                {
                                    goto Block_44;
                                }
                                goto IL_62F;
                            }
                            break;
                        }
                        if (!flag2)
                        {
                            goto Block_45;
                        }
                    }
                    else
                    {
                        if (num2 != 47)
                        {
                            if (num2 != 60)
                            {
                                if (num2 - 61 > 1)
                                {
                                    goto IL_62F;
                                }
                            }
                            else
                            {
                                if (!flag2)
                                {
                                    goto Block_41;
                                }
                                goto IL_62F;
                            }
                        }
                        if (!flag2 && this._inProcessingTag != 0)
                        {
                            goto Block_43;
                        }
                    }
IL_62F:
                    flag = true;
                    if (maker._outIndex < 512)
                    {
                        char[] outChars = maker._outChars;
                        Tokenizer.StringMaker stringMaker = maker;
                        int num3 = stringMaker._outIndex;
                        stringMaker._outIndex = num3 + 1;
                        outChars[num3]        = (ushort)num2;
                    }
                    else
                    {
                        if (maker._outStringBuilder == null)
                        {
                            maker._outStringBuilder = new StringBuilder();
                        }
                        maker._outStringBuilder.Append(maker._outChars, 0, 512);
                        maker._outChars[0] = (char)num2;
                        maker._outIndex    = 1;
                    }
                }
IL_48A:
                this._inProcessingTag++;
                stream.AddToken(0);
                continue;
Block_3:
                stream.AddToken(-1);
                return;

IL_4A4:
                this._inProcessingTag--;
                stream.AddToken(1);
                if (endAfterKet)
                {
                    return;
                }
                continue;
IL_4C0:
                stream.AddToken(4);
                continue;
Block_30:
                stream.AddToken(2);
                continue;
Block_31:
                stream.AddToken(5);
                continue;
Block_32:
                stream.AddToken(6);
                continue;
Block_33:
                stream.AddToken(7);
                continue;
Block_41:
                this._inSavedCharacter = num2;
                stream.AddToken(3);
                stream.AddString(this.GetStringToken());
                continue;
Block_43:
                this._inSavedCharacter = num2;
                stream.AddToken(3);
                stream.AddString(this.GetStringToken());
                continue;
Block_44:
                stream.AddToken(3);
                stream.AddString(this.GetStringToken());
                continue;
Block_45:
                stream.AddToken(3);
                stream.AddString(this.GetStringToken());
                continue;
Block_46:
                stream.AddToken(3);
                stream.AddString(this.GetStringToken());
                continue;
Block_4:
                stream.AddToken(-1);
                return;

IL_12D:
                throw new XmlSyntaxException(this.LineNo);
IL_14B:
                throw new XmlSyntaxException(this.LineNo);
Block_7:
                throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
Block_8:
                throw new XmlSyntaxException(this.LineNo);
Block_10:
                throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
Block_11:
                throw new XmlSyntaxException(this.LineNo);
Block_12:
                stream.AddToken(-1);
                return;

Block_13:
                stream.AddToken(-1);
                return;

Block_14:
                stream.AddToken(-1);
                return;

Block_17:
                stream.AddToken(-1);
                return;

Block_21:
                stream.AddToken(-1);
                return;
            }
        }
Beispiel #5
0
        internal void GetTokens(TokenizerStream stream, int maxNum, bool endAfterKet)
        {
            while ((maxNum == -1) || (stream.GetTokenCount() < maxNum))
            {
                int         num   = -1;
                int         num3  = 0;
                bool        flag  = false;
                bool        flag2 = false;
                StringMaker maker = this._maker;
                maker._outStringBuilder = null;
                maker._outIndex         = 0;
Label_0026:
                if (this._inSavedCharacter != -1)
                {
                    num = this._inSavedCharacter;
                    this._inSavedCharacter = -1;
                }
                else
                {
                    switch (this._inTokenSource)
                    {
                    case TokenSource.UnicodeByteArray:
                        if ((this._inIndex + 1) < this._inSize)
                        {
                            break;
                        }
                        stream.AddToken(-1);
                        return;

                    case TokenSource.UTF8ByteArray:
                        if (this._inIndex < this._inSize)
                        {
                            goto Label_00CF;
                        }
                        stream.AddToken(-1);
                        return;

                    case TokenSource.ASCIIByteArray:
                        if (this._inIndex < this._inSize)
                        {
                            goto Label_023C;
                        }
                        stream.AddToken(-1);
                        return;

                    case TokenSource.CharArray:
                        if (this._inIndex < this._inSize)
                        {
                            goto Label_0272;
                        }
                        stream.AddToken(-1);
                        return;

                    case TokenSource.String:
                        if (this._inIndex < this._inSize)
                        {
                            goto Label_02A8;
                        }
                        stream.AddToken(-1);
                        return;

                    case TokenSource.NestedStrings:
                        if (this._inNestedSize == 0)
                        {
                            goto Label_030D;
                        }
                        if (this._inNestedIndex >= this._inNestedSize)
                        {
                            goto Label_0306;
                        }
                        num = this._inNestedString[this._inNestedIndex++];
                        goto Label_0402;

                    default:
                        num = this._inTokenReader.Read();
                        if (num == -1)
                        {
                            stream.AddToken(-1);
                            return;
                        }
                        goto Label_0402;
                    }
                    num            = (this._inBytes[this._inIndex + 1] << 8) + this._inBytes[this._inIndex];
                    this._inIndex += 2;
                }
                goto Label_0402;
Label_00CF:
                num = this._inBytes[this._inIndex++];
                if ((num & 0x80) != 0)
                {
                    switch (((num & 240) >> 4))
                    {
                    case 8:
                    case 9:
                    case 10:
                    case 11:
                        throw new XmlSyntaxException(this.LineNo);

                    case 12:
                    case 13:
                        num &= 0x1f;
                        num3 = 2;
                        break;

                    case 14:
                        num &= 15;
                        num3 = 3;
                        break;

                    case 15:
                        throw new XmlSyntaxException(this.LineNo);
                    }
                    if (this._inIndex >= this._inSize)
                    {
                        throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                    }
                    byte num2 = this._inBytes[this._inIndex++];
                    if ((num2 & 0xc0) != 0x80)
                    {
                        throw new XmlSyntaxException(this.LineNo);
                    }
                    num = (num << 6) | (num2 & 0x3f);
                    if (num3 != 2)
                    {
                        if (this._inIndex >= this._inSize)
                        {
                            throw new XmlSyntaxException(this.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile"));
                        }
                        num2 = this._inBytes[this._inIndex++];
                        if ((num2 & 0xc0) != 0x80)
                        {
                            throw new XmlSyntaxException(this.LineNo);
                        }
                        num = (num << 6) | (num2 & 0x3f);
                    }
                }
                goto Label_0402;
Label_023C:
                num = this._inBytes[this._inIndex++];
                goto Label_0402;
Label_0272:
                num = this._inChars[this._inIndex++];
                goto Label_0402;
Label_02A8:
                num = this._inString[this._inIndex++];
                goto Label_0402;
Label_0306:
                this._inNestedSize = 0;
Label_030D:
                if (this._inIndex >= this._inSize)
                {
                    stream.AddToken(-1);
                    return;
                }
                num = this._inString[this._inIndex++];
                if (num == 0x7b)
                {
                    for (int i = 0; i < this._searchStrings.Length; i++)
                    {
                        if (string.Compare(this._searchStrings[i], 0, this._inString, this._inIndex - 1, this._searchStrings[i].Length, StringComparison.Ordinal) == 0)
                        {
                            this._inNestedString = this._replaceStrings[i];
                            this._inNestedSize   = this._inNestedString.Length;
                            this._inNestedIndex  = 1;
                            num            = this._inNestedString[0];
                            this._inIndex += this._searchStrings[i].Length - 1;
                            break;
                        }
                    }
                }
Label_0402:
                if (!flag)
                {
                    switch (num)
                    {
                    case 9:
                    case 13:
                    case 0x20:
                        goto Label_0026;

                    case 10:
                        this.LineNo++;
                        goto Label_0026;

                    case 0x21:
                    {
                        if (this._inProcessingTag == 0)
                        {
                            break;
                        }
                        stream.AddToken(6);
                        continue;
                    }

                    case 0x22:
                        flag  = true;
                        flag2 = true;
                        goto Label_0026;

                    case 0x2d:
                    {
                        if (this._inProcessingTag == 0)
                        {
                            break;
                        }
                        stream.AddToken(7);
                        continue;
                    }

                    case 0x2f:
                    {
                        if (this._inProcessingTag == 0)
                        {
                            break;
                        }
                        stream.AddToken(2);
                        continue;
                    }

                    case 60:
                    {
                        this._inProcessingTag++;
                        stream.AddToken(0);
                        continue;
                    }

                    case 0x3d:
                    {
                        stream.AddToken(4);
                        continue;
                    }

                    case 0x3e:
                        this._inProcessingTag--;
                        stream.AddToken(1);
                        if (!endAfterKet)
                        {
                            continue;
                        }
                        return;

                    case 0x3f:
                    {
                        if (this._inProcessingTag == 0)
                        {
                            break;
                        }
                        stream.AddToken(5);
                        continue;
                    }
                    }
                }
                else
                {
                    switch (num)
                    {
                    case 60:
                    {
                        if (flag2)
                        {
                            break;
                        }
                        this._inSavedCharacter = num;
                        stream.AddToken(3);
                        stream.AddString(this.GetStringToken());
                        continue;
                    }

                    case 0x3d:
                    case 0x3e:
                    case 0x2f:
                    {
                        if (flag2 || (this._inProcessingTag == 0))
                        {
                            break;
                        }
                        this._inSavedCharacter = num;
                        stream.AddToken(3);
                        stream.AddString(this.GetStringToken());
                        continue;
                    }

                    case 9:
                    case 13:
                    case 0x20:
                    {
                        if (flag2)
                        {
                            break;
                        }
                        stream.AddToken(3);
                        stream.AddString(this.GetStringToken());
                        continue;
                    }

                    case 10:
                        goto Label_0629;

                    case 0x22:
                    {
                        if (!flag2)
                        {
                            break;
                        }
                        stream.AddToken(3);
                        stream.AddString(this.GetStringToken());
                        continue;
                    }
                    }
                }
                goto Label_0650;
Label_0629:
                this.LineNo++;
                if (!flag2)
                {
                    stream.AddToken(3);
                    stream.AddString(this.GetStringToken());
                    continue;
                }
Label_0650:
                flag = true;
                if (maker._outIndex < 0x200)
                {
                    maker._outChars[maker._outIndex++] = (char)num;
                }
                else
                {
                    if (maker._outStringBuilder == null)
                    {
                        maker._outStringBuilder = new StringBuilder();
                    }
                    maker._outStringBuilder.Append(maker._outChars, 0, 0x200);
                    maker._outChars[0] = (char)num;
                    maker._outIndex    = 1;
                }
                goto Label_0026;
            }
        }