Ejemplo n.º 1
0
        private void Parse2(
            string statementText
            )
        {
//			Debug.WriteLine(statementText);

            PARSERSTATE parserState = PARSERSTATE.NOTHINGYET;

            Token[] namePart    = new Token[4];
            int     currentPart = 0;

            Token alias = Token.Null;

            TokenType lastTokenType = TokenType.Null;

            int parenLevel = 0;

//			bool			distinctFound;

            _columns = null;
            _tables  = null;

            Match match = SqlTokenParser.Match(statementText);
            Token token = TokenFromMatch(match);

            while (true)
            {
//				Debug.WriteLine(String.Format("{0,-15} {1,-17} {2} {3}", parserState, token.Type.ToString(), parenLevel, token.Value));

                switch (parserState)
                {
                case PARSERSTATE.DONE:
                    return;

                case PARSERSTATE.NOTHINGYET:
                    switch (token.Type)
                    {
                    case TokenType.Keyword_SELECT:
                        parserState = PARSERSTATE.SELECT;
                        break;

                    default:
                        Debug.Assert(false, "no state defined!!!!we should never be here!!!");
                        throw ADP.InvalidOperation(Res.GetString(Res.ADP_SQLParserInternalError));
                    }
                    break;

                case PARSERSTATE.SELECT:
                    switch (token.Type)
                    {
                    case TokenType.Identifier:
                    case TokenType.QuotedIdentifier:
                        parserState = PARSERSTATE.COLUMN;
                        currentPart = 0;
                        namePart[0] = token;
                        break;

                    case TokenType.Keyword_FROM:
                        parserState = PARSERSTATE.FROM;
                        break;

                    case TokenType.Other_Star:
                        parserState = PARSERSTATE.COLUMNALIAS;
                        currentPart = 0;
                        namePart[0] = token;
                        break;

                    case TokenType.Keyword_DISTINCT:
//								distinctFound = true;
                        break;

                    case TokenType.Keyword_ALL:
                        break;

                    case TokenType.Other_LeftParen:
                        parserState = PARSERSTATE.EXPRESSION;
                        parenLevel++;
                        break;

                    case TokenType.Other_RightParen:
                        throw ADP.SyntaxErrorMissingParenthesis();

                    default:
                        parserState = PARSERSTATE.EXPRESSION;
                        break;
                    }
                    break;

                case PARSERSTATE.COLUMN:
                    switch (token.Type)
                    {
                    case TokenType.Identifier:
                    case TokenType.QuotedIdentifier:
                        if (TokenType.Other_Period != lastTokenType)
                        {
                            parserState = PARSERSTATE.COLUMNALIAS;
                            alias       = token;
                        }
                        else
                        {
                            namePart[++currentPart] = token;
                        }
                        break;

                    case TokenType.Other_Period:
                        if (currentPart > 3)
                        {
                            throw ADP.SyntaxErrorTooManyNameParts();
                        }

                        break;

                    case TokenType.Other_Star:
                        parserState             = PARSERSTATE.COLUMNALIAS;
                        namePart[++currentPart] = token;
                        break;

                    case TokenType.Keyword_AS:
                        break;

                    case TokenType.Keyword_FROM:
                    case TokenType.Other_Comma:
                        parserState = (token.Type == TokenType.Keyword_FROM) ? PARSERSTATE.FROM : PARSERSTATE.SELECT;
                        AddColumn(currentPart, namePart, alias);
                        currentPart = -1;
                        alias       = Token.Null;
                        break;

                    case TokenType.Other_LeftParen:
                        parserState = PARSERSTATE.EXPRESSION;
                        parenLevel++;
                        currentPart = -1;
                        break;

                    case TokenType.Other_RightParen:
                        throw ADP.SyntaxErrorMissingParenthesis();

                    default:
                        parserState = PARSERSTATE.EXPRESSION;
                        currentPart = -1;
                        break;
                    }
                    break;

                case PARSERSTATE.COLUMNALIAS:
                    switch (token.Type)
                    {
                    case TokenType.Keyword_FROM:
                    case TokenType.Other_Comma:
                        parserState = (token.Type == TokenType.Keyword_FROM) ? PARSERSTATE.FROM : PARSERSTATE.SELECT;
                        AddColumn(currentPart, namePart, alias);
                        currentPart = -1;
                        alias       = Token.Null;
                        break;

                    default:
                        throw ADP.SyntaxErrorExpectedCommaAfterColumn();
                    }
                    break;

                case PARSERSTATE.EXPRESSION:
                    switch (token.Type)
                    {
                    case TokenType.Identifier:
                    case TokenType.QuotedIdentifier:
                        if (0 == parenLevel)
                        {
                            alias = token;
                        }
                        break;

                    case TokenType.Keyword_FROM:
                    case TokenType.Other_Comma:
                        if (0 == parenLevel)
                        {
                            parserState = (token.Type == TokenType.Keyword_FROM) ? PARSERSTATE.FROM : PARSERSTATE.SELECT;
                            AddColumn(currentPart, namePart, alias);
                            currentPart = -1;
                            alias       = Token.Null;
                        }
                        else
                        {
                            if (token.Type == TokenType.Keyword_FROM)
                            {
                                throw ADP.SyntaxErrorUnexpectedFrom();
                            }
                        }
                        break;

                    case TokenType.Other_LeftParen:
                        parenLevel++;
                        break;

                    case TokenType.Other_RightParen:
                        parenLevel--;
                        break;
                    }
                    break;

                case PARSERSTATE.FROM:
                    switch (token.Type)
                    {
                    case TokenType.Identifier:
                    case TokenType.QuotedIdentifier:
                        parserState = PARSERSTATE.TABLE;
                        currentPart = 0;
                        namePart[0] = token;
                        break;

                    default:
                        throw ADP.SyntaxErrorExpectedIdentifier();
                    }
                    break;

                case PARSERSTATE.TABLE:
                    switch (token.Type)
                    {
                    case TokenType.Identifier:
                    case TokenType.QuotedIdentifier:
                        if (TokenType.Other_Period != lastTokenType)
                        {
                            parserState = PARSERSTATE.TABLEALIAS;
                            alias       = token;
                        }
                        else
                        {
                            namePart[++currentPart] = token;
                        }
                        break;

                    case TokenType.Other_Period:
                        if (currentPart > 2)
                        {
                            throw ADP.SyntaxErrorTooManyNameParts();
                        }

                        break;

                    case TokenType.Keyword_AS:
                        break;

                    case TokenType.Keyword_COMPUTE:
                    case TokenType.Keyword_FOR:
                    case TokenType.Keyword_GROUP:
                    case TokenType.Keyword_HAVING:
                    case TokenType.Keyword_INTERSECT:
                    case TokenType.Keyword_MINUS:
                    case TokenType.Keyword_ORDER:
                    case TokenType.Keyword_UNION:
                    case TokenType.Keyword_WHERE:
                    case TokenType.Null:

                    case TokenType.Other_Comma:
                        parserState = (TokenType.Other_Comma == token.Type) ? PARSERSTATE.FROM : PARSERSTATE.DONE;
                        AddTable(currentPart, namePart, alias);
                        currentPart = -1;
                        alias       = Token.Null;
                        break;

                    default:
                        throw ADP.SyntaxErrorExpectedNextPart();
                    }
                    break;

                case PARSERSTATE.TABLEALIAS:
                    switch (token.Type)
                    {
                    case TokenType.Keyword_COMPUTE:
                    case TokenType.Keyword_FOR:
                    case TokenType.Keyword_GROUP:
                    case TokenType.Keyword_HAVING:
                    case TokenType.Keyword_INTERSECT:
                    case TokenType.Keyword_MINUS:
                    case TokenType.Keyword_ORDER:
                    case TokenType.Keyword_UNION:
                    case TokenType.Keyword_WHERE:
                    case TokenType.Null:

                    case TokenType.Other_Comma:
                        parserState = (TokenType.Other_Comma == token.Type) ? PARSERSTATE.FROM : PARSERSTATE.DONE;
                        AddTable(currentPart, namePart, alias);
                        currentPart = -1;
                        alias       = Token.Null;
                        break;

                    default:
                        throw ADP.SyntaxErrorExpectedCommaAfterTable();
                    }
                    break;


                default:
                    Debug.Assert(false, "no state defined!!!!we should never be here!!!");
                    throw ADP.InvalidOperation(Res.GetString(Res.ADP_SQLParserInternalError));
                }

                lastTokenType = token.Type;

                match = match.NextMatch();
                token = TokenFromMatch(match);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 从连接串中的currentPosition位置开始找到第一个名称/值对
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="currentPosition"></param>
        /// <param name="key"></param>
        /// <param name="valuebuf"></param>
        /// <param name="vallength"></param>
        /// <param name="isempty"></param>
        /// <returns></returns>
        private static int GetKeyValuePair(char[] connectionString, int currentPosition, out string key, char[] valuebuf, out int vallength, out bool isempty)
        {
            PARSERSTATE parserstate1 = PARSERSTATE.NothingYet;
            int         num1         = 0;
            int         num2         = currentPosition;

            key       = null;
            vallength = -1;
            isempty   = false;
            char ch1 = '\0';

            while (currentPosition < connectionString.Length)
            {
                ch1 = connectionString[currentPosition];
                switch (parserstate1)
                {
                case PARSERSTATE.NothingYet:
                    if ((';' != ch1) && !char.IsWhiteSpace(ch1))
                    {
                        num2 = currentPosition;
                        if (ch1 != '\0')
                        {
                            break;
                        }
                        parserstate1 = PARSERSTATE.NullTermination;
                    }
                    goto Label_01E4;

                case PARSERSTATE.Key:
                    if ('=' != ch1)
                    {
                        goto Label_00A2;
                    }
                    parserstate1 = PARSERSTATE.KeyEqual;
                    goto Label_01E4;

                case PARSERSTATE.KeyEqual:
                    goto Label_00C0;

                case PARSERSTATE.KeyEnd:
                    goto Label_00D9;

                case PARSERSTATE.UnquotedValue:
                    if (char.IsWhiteSpace(ch1) || (!char.IsControl(ch1) && (';' != ch1)))
                    {
                        goto Label_01DC;
                    }
                    goto Label_0216;

                case PARSERSTATE.DoubleQuoteValue:
                    if ('"' != ch1)
                    {
                        goto Label_0151;
                    }
                    parserstate1 = PARSERSTATE.DoubleQuoteValueQuote;
                    goto Label_01E4;

                case PARSERSTATE.DoubleQuoteValueQuote:
                    goto Label_015F;

                case PARSERSTATE.DoubleQuoteValueEnd:
                    goto Label_016A;

                case PARSERSTATE.SingleQuoteValue:
                    goto Label_018A;

                case PARSERSTATE.SingleQuoteValueQuote:
                    goto Label_019F;

                case PARSERSTATE.SingleQuoteValueEnd:
                    goto Label_01AC;

                case PARSERSTATE.NullTermination:
                    goto Label_01C9;

                default:
                    goto Label_01DC;
                }
                if (char.IsControl(ch1))
                {
                    throw ConnectionStringSyntax(currentPosition, connectionString);
                }
                parserstate1 = PARSERSTATE.Key;
                num1         = 0;
                goto Label_01DC;
Label_00A2:
                if (char.IsWhiteSpace(ch1) || !char.IsControl(ch1))
                {
                    goto Label_01DC;
                }
                throw ConnectionStringSyntax(currentPosition, connectionString);
Label_00C0:
                if ('=' == ch1)
                {
                    parserstate1 = PARSERSTATE.Key;
                    goto Label_01DC;
                }
                key          = GetKey(valuebuf, num1);
                num1         = 0;
                parserstate1 = PARSERSTATE.KeyEnd;
Label_00D9:
                if (char.IsWhiteSpace(ch1))
                {
                    goto Label_01E4;
                }
                if ('\'' == ch1)
                {
                    parserstate1 = PARSERSTATE.SingleQuoteValue;
                    goto Label_01E4;
                }
                if ('"' == ch1)
                {
                    parserstate1 = PARSERSTATE.DoubleQuoteValue;
                    goto Label_01E4;
                }
                if ((';' == ch1) || (ch1 == '\0'))
                {
                    goto Label_0216;
                }
                if (char.IsControl(ch1))
                {
                    throw ConnectionStringSyntax(currentPosition, connectionString);
                }
                parserstate1 = PARSERSTATE.UnquotedValue;
                goto Label_01DC;
Label_0151:
                if (ch1 != '\0')
                {
                    goto Label_01DC;
                }
                throw ConnectionStringSyntax(currentPosition, connectionString);
Label_015F:
                if ('"' == ch1)
                {
                    parserstate1 = PARSERSTATE.DoubleQuoteValue;
                    goto Label_01DC;
                }
                parserstate1 = PARSERSTATE.DoubleQuoteValueEnd;
Label_016A:
                if (char.IsWhiteSpace(ch1))
                {
                    goto Label_01E4;
                }
                if (';' == ch1)
                {
                    goto Label_0216;
                }
                if (ch1 == '\0')
                {
                    parserstate1 = PARSERSTATE.NullTermination;
                    goto Label_01E4;
                }
                throw ConnectionStringSyntax(currentPosition, connectionString);
Label_018A:
                if ('\'' == ch1)
                {
                    parserstate1 = PARSERSTATE.SingleQuoteValueQuote;
                    goto Label_01E4;
                }
                if (ch1 != '\0')
                {
                    goto Label_01DC;
                }
                throw ConnectionStringSyntax(currentPosition, connectionString);
Label_019F:
                if ('\'' == ch1)
                {
                    parserstate1 = PARSERSTATE.SingleQuoteValue;
                    goto Label_01DC;
                }
                parserstate1 = PARSERSTATE.SingleQuoteValueEnd;
Label_01AC:
                if (char.IsWhiteSpace(ch1))
                {
                    goto Label_01E4;
                }
                if (';' == ch1)
                {
                    goto Label_0216;
                }
                if (ch1 == '\0')
                {
                    parserstate1 = PARSERSTATE.NullTermination;
                    goto Label_01E4;
                }
                throw ConnectionStringSyntax(currentPosition, connectionString);
Label_01C9:
                if ((ch1 == '\0') || char.IsWhiteSpace(ch1))
                {
                    goto Label_01E4;
                }
                throw ConnectionStringSyntax(num2, connectionString);
Label_01DC:
                valuebuf[num1++] = ch1;
Label_01E4:
                currentPosition++;
            }
            if (PARSERSTATE.KeyEqual == parserstate1)
            {
                key  = GetKey(valuebuf, num1);
                num1 = 0;
            }
            if (((PARSERSTATE.Key == parserstate1) || (PARSERSTATE.DoubleQuoteValue == parserstate1)) || (PARSERSTATE.SingleQuoteValue == parserstate1))
            {
                throw ConnectionStringSyntax(num2, connectionString);
            }
Label_0216:
            if (PARSERSTATE.UnquotedValue == parserstate1)
            {
                num1 = TrimWhiteSpace(valuebuf, num1);
                if (('\'' == valuebuf[num1 - 1]) || ('"' == valuebuf[num1 - 1]))
                {
                    throw ConnectionStringSyntax(currentPosition - 1, connectionString);
                }
            }
            else if ((PARSERSTATE.KeyEqual != parserstate1) && (PARSERSTATE.KeyEnd != parserstate1))
            {
                isempty = 0 == num1;
            }
            if ((';' == ch1) && (currentPosition < connectionString.Length))
            {
                currentPosition++;
            }
            vallength = num1;
            return(currentPosition);
        }
        private void Parse2(string statementText)
        {
            bool        flag;
            PARSERSTATE nOTHINGYET = PARSERSTATE.NOTHINGYET;

            Token[]   namePart = new Token[4];
            int       maxPart  = 0;
            Token     @null    = Token.Null;
            TokenType type7    = TokenType.Null;
            int       num2     = 0;

            this._columns = null;
            this._tables  = null;
            Match match  = SqlTokenParser.Match(statementText);
            Token token2 = TokenFromMatch(match);

Label_003B:
            flag = false;
            switch (nOTHINGYET)
            {
            case PARSERSTATE.NOTHINGYET:
                if (token2.Type != TokenType.Keyword_SELECT)
                {
                    throw System.Data.Common.ADP.InvalidOperation(Res.GetString("ADP_SQLParserInternalError"));
                }
                nOTHINGYET = PARSERSTATE.SELECT;
                goto Label_061A;

            case PARSERSTATE.SELECT:
            {
                TokenType type2 = token2.Type;
                if (type2 > TokenType.Other_Star)
                {
                    switch (type2)
                    {
                    case TokenType.Keyword_DISTINCT:
                    case TokenType.Keyword_ALL:
                        goto Label_061A;

                    case TokenType.Keyword_FROM:
                        nOTHINGYET = PARSERSTATE.FROM;
                        goto Label_061A;
                    }
                    break;
                }
                switch (type2)
                {
                case TokenType.Identifier:
                case TokenType.QuotedIdentifier:
                    nOTHINGYET  = PARSERSTATE.COLUMN;
                    maxPart     = 0;
                    namePart[0] = token2;
                    goto Label_061A;

                case TokenType.Other_LeftParen:
                    nOTHINGYET = PARSERSTATE.EXPRESSION;
                    num2++;
                    goto Label_061A;

                case TokenType.Other_RightParen:
                    throw System.Data.Common.ADP.SyntaxErrorMissingParenthesis();

                case TokenType.Other_Star:
                    nOTHINGYET  = PARSERSTATE.COLUMNALIAS;
                    maxPart     = 0;
                    namePart[0] = token2;
                    goto Label_061A;
                }
                break;
            }

            case PARSERSTATE.COLUMN:
            {
                TokenType type = token2.Type;
                if (type > TokenType.Other_Star)
                {
                    switch (type)
                    {
                    case TokenType.Keyword_AS:
                        goto Label_061A;

                    case TokenType.Keyword_FROM:
                        goto Label_01FF;
                    }
                }
                else
                {
                    switch (type)
                    {
                    case TokenType.Identifier:
                    case TokenType.QuotedIdentifier:
                        if (TokenType.Other_Period != type7)
                        {
                            nOTHINGYET = PARSERSTATE.COLUMNALIAS;
                            @null      = token2;
                        }
                        else
                        {
                            namePart[++maxPart] = token2;
                        }
                        goto Label_061A;

                    case TokenType.Other_Comma:
                        goto Label_01FF;

                    case TokenType.Other_Period:
                        if (maxPart > 3)
                        {
                            throw System.Data.Common.ADP.SyntaxErrorTooManyNameParts();
                        }
                        goto Label_061A;

                    case TokenType.Other_LeftParen:
                        nOTHINGYET = PARSERSTATE.EXPRESSION;
                        num2++;
                        maxPart = -1;
                        goto Label_061A;

                    case TokenType.Other_RightParen:
                        throw System.Data.Common.ADP.SyntaxErrorMissingParenthesis();

                    case TokenType.Other_Star:
                        nOTHINGYET          = PARSERSTATE.COLUMNALIAS;
                        namePart[++maxPart] = token2;
                        goto Label_061A;
                    }
                }
                nOTHINGYET = PARSERSTATE.EXPRESSION;
                maxPart    = -1;
                goto Label_061A;
            }

            case PARSERSTATE.COLUMNALIAS:
            {
                TokenType type9 = token2.Type;
                if ((type9 != TokenType.Other_Comma) && (type9 != TokenType.Keyword_FROM))
                {
                    throw System.Data.Common.ADP.SyntaxErrorExpectedCommaAfterColumn();
                }
                nOTHINGYET = (token2.Type == TokenType.Keyword_FROM) ? PARSERSTATE.FROM : PARSERSTATE.SELECT;
                this.AddColumn(maxPart, namePart, @null);
                maxPart = -1;
                @null   = Token.Null;
                goto Label_061A;
            }

            case PARSERSTATE.TABLE:
                switch (token2.Type)
                {
                case TokenType.Null:
                case TokenType.Keyword_COMPUTE:
                case TokenType.Keyword_FOR:
                case TokenType.Keyword_GROUP:
                case TokenType.Keyword_HAVING:
                case TokenType.Keyword_INTERSECT:
                case TokenType.Keyword_MINUS:
                case TokenType.Keyword_ORDER:
                case TokenType.Keyword_UNION:
                case TokenType.Keyword_WHERE:
                    nOTHINGYET = PARSERSTATE.DONE;
                    flag       = true;
                    goto Label_061A;

                case TokenType.Identifier:
                case TokenType.QuotedIdentifier:
                    if (TokenType.Other_Period != type7)
                    {
                        nOTHINGYET = PARSERSTATE.TABLEALIAS;
                        @null      = token2;
                    }
                    else
                    {
                        namePart[++maxPart] = token2;
                    }
                    goto Label_061A;

                case TokenType.Other_Comma:
                case TokenType.Keyword_JOIN:
                    nOTHINGYET = PARSERSTATE.FROM;
                    flag       = true;
                    goto Label_061A;

                case TokenType.Other_Period:
                    if (maxPart > 2)
                    {
                        throw System.Data.Common.ADP.SyntaxErrorTooManyNameParts();
                    }
                    goto Label_061A;

                case TokenType.Keyword_AS:
                    goto Label_061A;

                case TokenType.Keyword_CROSS:
                case TokenType.Keyword_LEFT:
                case TokenType.Keyword_NATURAL:
                case TokenType.Keyword_RIGHT:
                    nOTHINGYET = PARSERSTATE.JOIN;
                    flag       = true;
                    goto Label_061A;

                case TokenType.Keyword_ON:
                case TokenType.Keyword_USING:
                    nOTHINGYET = PARSERSTATE.JOINCONDITION;
                    flag       = true;
                    goto Label_061A;
                }
                throw System.Data.Common.ADP.SyntaxErrorExpectedNextPart();

            case PARSERSTATE.TABLEALIAS:
                flag = true;
                switch (token2.Type)
                {
                case TokenType.Keyword_COMPUTE:
                case TokenType.Keyword_FOR:
                case TokenType.Keyword_GROUP:
                case TokenType.Keyword_HAVING:
                case TokenType.Keyword_INTERSECT:
                case TokenType.Keyword_MINUS:
                case TokenType.Keyword_ORDER:
                case TokenType.Keyword_UNION:
                case TokenType.Keyword_WHERE:
                case TokenType.Null:
                    nOTHINGYET = PARSERSTATE.DONE;
                    goto Label_061A;

                case TokenType.Keyword_CROSS:
                case TokenType.Keyword_LEFT:
                case TokenType.Keyword_NATURAL:
                case TokenType.Keyword_RIGHT:
                    nOTHINGYET = PARSERSTATE.JOIN;
                    goto Label_061A;

                case TokenType.Keyword_JOIN:
                case TokenType.Other_Comma:
                    nOTHINGYET = PARSERSTATE.FROM;
                    goto Label_061A;

                case TokenType.Keyword_ON:
                case TokenType.Keyword_USING:
                    nOTHINGYET = PARSERSTATE.JOINCONDITION;
                    goto Label_061A;
                }
                throw System.Data.Common.ADP.SyntaxErrorExpectedCommaAfterTable();

            case PARSERSTATE.FROM:
                switch (token2.Type)
                {
                case TokenType.Identifier:
                case TokenType.QuotedIdentifier:
                    nOTHINGYET  = PARSERSTATE.TABLE;
                    maxPart     = 0;
                    namePart[0] = token2;
                    goto Label_061A;
                }
                throw System.Data.Common.ADP.SyntaxErrorExpectedIdentifier();

            case PARSERSTATE.EXPRESSION:
                switch (token2.Type)
                {
                case TokenType.Identifier:
                case TokenType.QuotedIdentifier:
                    if (num2 == 0)
                    {
                        @null = token2;
                    }
                    break;

                case TokenType.Other_Comma:
                case TokenType.Keyword_FROM:
                    if (num2 == 0)
                    {
                        nOTHINGYET = (token2.Type == TokenType.Keyword_FROM) ? PARSERSTATE.FROM : PARSERSTATE.SELECT;
                        this.AddColumn(maxPart, namePart, @null);
                        maxPart = -1;
                        @null   = Token.Null;
                    }
                    break;

                case TokenType.Other_LeftParen:
                    num2++;
                    break;

                case TokenType.Other_RightParen:
                    num2--;
                    break;
                }
                goto Label_061A;

            case PARSERSTATE.JOIN:
                switch (token2.Type)
                {
                case TokenType.Keyword_INNER:
                case TokenType.Keyword_OUTER:
                    goto Label_061A;

                case TokenType.Keyword_JOIN:
                    nOTHINGYET = PARSERSTATE.FROM;
                    goto Label_061A;
                }
                throw System.Data.Common.ADP.SyntaxErrorExpectedNextPart();

            case PARSERSTATE.JOINCONDITION:
                switch (token2.Type)
                {
                case TokenType.Other_LeftParen:
                    num2++;
                    goto Label_061A;

                case TokenType.Other_RightParen:
                    num2--;
                    goto Label_061A;
                }
                if (num2 == 0)
                {
                    switch (token2.Type)
                    {
                    case TokenType.Keyword_COMPUTE:
                    case TokenType.Keyword_FOR:
                    case TokenType.Keyword_GROUP:
                    case TokenType.Keyword_HAVING:
                    case TokenType.Keyword_INTERSECT:
                    case TokenType.Keyword_MINUS:
                    case TokenType.Keyword_ORDER:
                    case TokenType.Keyword_UNION:
                    case TokenType.Keyword_WHERE:
                    case TokenType.Null:
                        nOTHINGYET = PARSERSTATE.DONE;
                        break;

                    case TokenType.Keyword_CROSS:
                    case TokenType.Keyword_LEFT:
                    case TokenType.Keyword_NATURAL:
                    case TokenType.Keyword_RIGHT:
                        nOTHINGYET = PARSERSTATE.JOIN;
                        break;

                    case TokenType.Keyword_JOIN:
                        nOTHINGYET = PARSERSTATE.FROM;
                        break;
                    }
                }
                goto Label_061A;

            case PARSERSTATE.DONE:
                return;

            default:
                throw System.Data.Common.ADP.InvalidOperation(Res.GetString("ADP_SQLParserInternalError"));
            }
            nOTHINGYET = PARSERSTATE.EXPRESSION;
            goto Label_061A;
Label_01FF:
            nOTHINGYET = (token2.Type == TokenType.Keyword_FROM) ? PARSERSTATE.FROM : PARSERSTATE.SELECT;
            this.AddColumn(maxPart, namePart, @null);
            maxPart = -1;
            @null   = Token.Null;
Label_061A:
            if (flag)
            {
                this.AddTable(maxPart, namePart, @null);
                maxPart = -1;
                @null   = Token.Null;
                flag    = false;
            }
            type7  = token2.Type;
            match  = match.NextMatch();
            token2 = TokenFromMatch(match);
            goto Label_003B;
        }
        internal static long ParseServerVersion(string versionString)
        {
            PARSERSTATE nOTHINGYET = PARSERSTATE.NOTHINGYET;
            int         startIndex = 0;
            int         num2       = 0;
            long        num3       = 0L;

            versionString = versionString + "0.0.0.0.0 ";
            for (int i = 0; i < versionString.Length; i++)
            {
                switch (nOTHINGYET)
                {
                case PARSERSTATE.NOTHINGYET:
                {
                    if (char.IsDigit(versionString, i))
                    {
                        nOTHINGYET = PARSERSTATE.DIGIT;
                        startIndex = i;
                    }
                    continue;
                }

                case PARSERSTATE.PERIOD:
                {
                    if (!char.IsDigit(versionString, i))
                    {
                        break;
                    }
                    nOTHINGYET = PARSERSTATE.DIGIT;
                    startIndex = i;
                    continue;
                }

                case PARSERSTATE.DIGIT:
                {
                    if (!("." == versionString.Substring(i, 1)) && (4 != num2))
                    {
                        goto Label_00AB;
                    }
                    num2++;
                    nOTHINGYET = PARSERSTATE.PERIOD;
                    long num5 = int.Parse(versionString.Substring(startIndex, i - startIndex), CultureInfo.InvariantCulture);
                    num3 = (num3 << 8) + num5;
                    if (5 != num2)
                    {
                        continue;
                    }
                    return(num3);
                }

                default:
                {
                    continue;
                }
                }
                nOTHINGYET = PARSERSTATE.NOTHINGYET;
                num2       = 0;
                num3       = 0L;
                continue;
Label_00AB:
                if (!char.IsDigit(versionString, i))
                {
                    nOTHINGYET = PARSERSTATE.NOTHINGYET;
                    num2       = 0;
                    num3       = 0L;
                }
            }
            return(0L);
        }