protected int Match(params MySQLToken[] expectToken)
        {
            if (expectToken == null || expectToken.Length <= 0)
            {
                throw new ArgumentException("at least one expect token");
            }
            MySQLToken token = lexer.Token();

            for (int i = 0; i < expectToken.Length; ++i)
            {
                if (token == expectToken[i])
                {
                    if (token != MySQLToken.EOF || i < expectToken.Length - 1)
                    {
                        lexer.NextToken();
                    }
                    return(i);
                }
            }
            throw new ArgumentException("expect " + expectToken);
        }
        public static IStatement Parse(string sql, MySQLLexer lexer, string charset)
        {
            try
            {
                IStatement      stmt;
                bool            isEOF      = true;
                MySQLExprParser exprParser = new MySQLExprParser(lexer, charset);
StmtSwitch:
                switch (lexer.Token())
                {
                //TODO:之后加入DAL的解析后,要改
                case MySQLToken.KW_SELECT:
                case MySQLToken.PUNC_LEFT_PAREN:
                    stmt = new SelectStatement
                           goto StmtSwitch;

                case MySQLToken.KW_DELETE:
                    goto StmtSwitch;

                case MySQLToken.KW_INSERT:
                    goto StmtSwitch;

                case MySQLToken.KW_REPLACE:
                    goto StmtSwitch;

                case MySQLToken.KW_UPDATE:
                    goto StmtSwitch;

                case MySQLToken.KW_CALL:
                    goto StmtSwitch;

                case MySQLToken.KW_SET:
                    goto StmtSwitch;

                case MySQLToken.KW_SHOW:
                    goto StmtSwitch;

                case MySQLToken.KW_ALTER:
                case MySQLToken.KW_CREATE:
                case MySQLToken.KW_DROP:
                case MySQLToken.KW_RENAME:
                    goto StmtSwitch;

                case MySQLToken.KW_RELEASE:
                    goto StmtSwitch;

                case MySQLToken.IDENTIFIER:
                    goto StmtSwitch;

                default:
                    throw new SystemException("sql is not a supported statement");
                }
                if (isEOF)
                {
                    while (lexer.Token() == MySQLToken.PUNC_SEMICOLON)
                    {
                        lexer.NextToken();
                    }
                    if (lexer.Token() != MySQLToken.EOF)
                    {
                        throw new SystemException("SQL syntax error!");
                    }
                }
                return(stmt);
            }
            catch (Exception ex)
            {
                throw new SystemException(BuildErrorMsg(ex, lexer, sql));
            }
        }