NextToken() public method

public NextToken ( ) : MySqlToken
return MySqlToken
 public virtual void TestPlaceHolder()
 {
     var sut = new MySqlLexer(" ${abc}. ");
     Assert.AreEqual(MySqlToken.PlaceHolder, sut.Token());
     Assert.AreEqual("abc", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(" ${abc");
     Assert.AreEqual(MySqlToken.PlaceHolder, sut.Token());
     Assert.AreEqual("abc", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(" ${abc}");
     Assert.AreEqual(MySqlToken.PlaceHolder, sut.Token());
     Assert.AreEqual("abc", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(" ${abc}abn");
     Assert.AreEqual(MySqlToken.PlaceHolder, sut.Token());
     Assert.AreEqual("abc", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("abn", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(" ${abc12@,,.~`*-_$}}}}");
     Assert.AreEqual(MySqlToken.PlaceHolder, sut.Token());
     Assert.AreEqual("abc12@,,.~`*-_$", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncRightBrace, sut.Token());
     sut.NextToken();
     sut.NextToken();
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(" #${abc\n,${abc12@,,.~`*-_$}");
     Assert.AreEqual(MySqlToken.PuncComma, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PlaceHolder, sut.Token());
     Assert.AreEqual("abc12@,,.~`*-_$", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("${abc(123,345)} ,");
     Assert.AreEqual(MySqlToken.PlaceHolder, sut.Token());
     Assert.AreEqual("abc(123,345)", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncComma, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
 }
        /// <exception cref="System.SqlSyntaxErrorException" />
        public static ISqlStatement Parse(string sql, MySqlLexer lexer, string charset)
        {
            try
            {
                ISqlStatement stmt = null;
                var isEof = true;
                var exprParser = new MySqlExprParser(lexer, charset);
                switch (lexer.Token())
                {
                    case MySqlToken.KwDesc:
                    case MySqlToken.KwDescribe:
                    {
                        stmt = new MySqlDalParser(lexer, exprParser).Desc();
                        goto stmtSwitch_break;
                    }

                    case MySqlToken.KwSelect:
                    case MySqlToken.PuncLeftParen:
                    {
                        stmt = new MySqlDmlSelectParser(lexer, exprParser).SelectUnion();
                        goto stmtSwitch_break;
                    }

                    case MySqlToken.KwDelete:
                    {
                        stmt = new MySqlDmlDeleteParser(lexer, exprParser).Delete();
                        goto stmtSwitch_break;
                    }

                    case MySqlToken.KwInsert:
                    {
                        stmt = new MySqlDmlInsertParser(lexer, exprParser).Insert();
                        goto stmtSwitch_break;
                    }

                    case MySqlToken.KwReplace:
                    {
                        stmt = new MySqlDmlReplaceParser(lexer, exprParser).Replace();
                        goto stmtSwitch_break;
                    }

                    case MySqlToken.KwUpdate:
                    {
                        stmt = new MySqlDmlUpdateParser(lexer, exprParser).Update();
                        goto stmtSwitch_break;
                    }

                    case MySqlToken.KwCall:
                    {
                        stmt = new MySqlDmlCallParser(lexer, exprParser).Call();
                        goto stmtSwitch_break;
                    }

                    case MySqlToken.KwSet:
                    {
                        stmt = new MySqlDalParser(lexer, exprParser).Set();
                        goto stmtSwitch_break;
                    }

                    case MySqlToken.KwShow:
                    {
                        stmt = new MySqlDalParser(lexer, exprParser).Show();
                        goto stmtSwitch_break;
                    }

                    case MySqlToken.KwAlter:
                    case MySqlToken.KwCreate:
                    case MySqlToken.KwDrop:
                    case MySqlToken.KwRename:
                    {
                        stmt = new MySqlDdlParser(lexer, exprParser).DdlStmt();
                        isEof = IsEOFedDdl(stmt);
                        goto stmtSwitch_break;
                    }

                    case MySqlToken.KwRelease:
                    {
                        stmt = new MySqlMtsParser(lexer).Release();
                        goto stmtSwitch_break;
                    }

                    case MySqlToken.Identifier:
                    {
                        var si = SpecialIdentifier.None;
                        if ((si = SpecialIdentifiers[lexer.GetStringValueUppercase()]) != SpecialIdentifier.None)
                        {
                            switch (si)
                            {
                                case SpecialIdentifier.Truncate:
                                {
                                    stmt = new MySqlDdlParser(lexer, exprParser).Truncate();
                                    goto stmtSwitch_break;
                                }

                                case SpecialIdentifier.Savepoint:
                                {
                                    stmt = new MySqlMtsParser(lexer).Savepoint();
                                    goto stmtSwitch_break;
                                }

                                case SpecialIdentifier.Rollback:
                                {
                                    stmt = new MySqlMtsParser(lexer).Rollback();
                                    goto stmtSwitch_break;
                                }
                            }
                        }
                        goto default;
                    }

                    default:
                    {
                        throw new SqlSyntaxErrorException("sql is not a supported statement");
                    }
                }
                stmtSwitch_break:
                ;
                if (isEof)
                {
                    while (lexer.Token() == MySqlToken.PuncSemicolon)
                    {
                        lexer.NextToken();
                    }
                    if (lexer.Token() != MySqlToken.Eof)
                    {
                        throw new SqlSyntaxErrorException("Sql syntax error!");
                    }
                }
                return stmt;
            }
            catch (Exception e)
            {
                throw new SqlSyntaxErrorException(BuildErrorMsg(e, lexer, sql), e);
            }
        }
 public virtual void TestNumber()
 {
     var sut =
         new MySqlLexer(" . 12e3/***/.12e3#/**\n.123ee123.1--  \r\t\n.12e/*a*//* !*/.12e_a/12e-- \r\t.12e-1");
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("12000", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("120", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("123ee123", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("0.1", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("12e", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("12e_a", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpSlash, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("12e", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(".12e-1  ");
     Assert.AreEqual("0.012", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("12e000000000000000  ");
     Assert.AreEqual("12", sut.GetDecimalValue().ToPlainString());
     sut = new MySqlLexer(".12e-  ");
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("12e", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpMinus, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(".12e-1d  ");
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("12e", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpMinus, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("1d", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("12.e+1d  ");
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("120", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("d", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("12.f ");
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("12", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("f", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(".12f ");
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("12f", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("1.2f ");
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("1.2", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("f", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     try
     {
         sut = new MySqlLexer("12.e ");
         Assert.IsFalse(true, "should not reach here");
     }
     catch (SqlSyntaxErrorException)
     {
     }
     sut = new MySqlLexer("0e  ");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("0e", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("12. e  ");
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("12", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("e", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("12. e+1  ");
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("12", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("e", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpPlus, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralNumPureDigit, sut.Token());
     Assert.AreEqual("1", sut.GetIntegerValue().ToString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("12.e+1  ");
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("120", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("12.");
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("12", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(".12");
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("0.12", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("12e");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("12e", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("12ef");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("12ef", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(".12e");
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("12e", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("1.0e0");
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("1.0", sut.GetDecimalValue().ToPlainString());
     sut = new MySqlLexer("1.01e0,");
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("1.01", sut.GetDecimalValue().ToPlainString());
     sut = new MySqlLexer(".12e-");
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("12e", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpMinus, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(".12e-d");
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("12e", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpMinus, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("d", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("123E2.*");
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("12300", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpAsterisk, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("1e-1  ");
     Assert.AreEqual("0.1", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(".E5");
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("E5", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("0E5d");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("0E5d", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("0E10");
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("0", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(".   ");
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("12345678901234567890123 1234567890 1234567890123456789");
     Assert.AreEqual(MySqlToken.LiteralNumPureDigit, sut.Token());
     Assert.AreEqual("12345678901234567890123", sut.GetIntegerValue().ToString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralNumPureDigit, sut.Token());
     Assert.AreEqual("1234567890", sut.GetIntegerValue().ToString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralNumPureDigit, sut.Token());
     Assert.AreEqual("1234567890123456789", sut.GetIntegerValue().ToString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(".");
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
 }
 public virtual void TestParameter()
 {
     var sut = new MySqlLexer("?,?,?");
     Assert.AreEqual(MySqlToken.QuestionMark, sut.Token());
     Assert.AreEqual(1, sut.ParamIndex);
     sut.NextToken();
     sut.NextToken();
     Assert.AreEqual(MySqlToken.QuestionMark, sut.Token());
     Assert.AreEqual(2, sut.ParamIndex);
     sut.NextToken();
     sut.NextToken();
     Assert.AreEqual(MySqlToken.QuestionMark, sut.Token());
     Assert.AreEqual(3, sut.ParamIndex);
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
 }
 public virtual void TestId1()
 {
     var sut = new MySqlLexer("id . 12e3f /***/`12\\3```-- d\n \r#\r  ##\n\t123d");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("12e3f", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("`12\\3```", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("123d", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("`ab``c`");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("`ab``c`", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("`,\"'\\//*$#\nab``c  -`");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("`,\"'\\//*$#\nab``c  -`", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("`ab````c```");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("`ab````c```", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("`ab`````c``````");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("`ab`````", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("c", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("``````", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("n123 \t b123 x123");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("n123", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("b123", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("x123", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("n邱 硕");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("n邱", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("硕", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("n邱硕");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("n邱硕", sut.GetStringValue());
     sut.NextToken();
     sut = new MySqlLexer(" $abc");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("$abc", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("$abc  ");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("$abc", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(" $abc  ");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("$abc", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(" 123d +=_&*_1a^abc-- $123");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("123d", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpPlus, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpEquals, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("_", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpAmpersand, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpAsterisk, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("_1a", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpCaret, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("abc", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(" $abc  ,#$abc\n{`_``12`(123a)_abcnd; //x123");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("$abc", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncComma, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncLeftBrace, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("`_``12`", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncLeftParen, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("123a", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncRightParen, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("_abcnd", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncSemicolon, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpSlash, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpSlash, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("x123", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
 }
 public virtual void TestLexer()
 {
     var sut = new MySqlLexer(" @a.1_$ .1e+1a%x'a1e'*0b11a \r#\"\"\n@@`123`@@'abc'1.e-1d`/`1.1e1.1e1");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@a.1_$", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("1e", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpPlus, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("1a", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpPercent, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralHex, sut.Token());
     Assert.AreEqual("a1e", new string(sut.Sql, sut.OffsetCache, sut.SizeCache));
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpAsterisk, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("0b11a", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual("`123`", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual(string.Empty, sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'abc'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("0.1", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("d", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("`/`", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("11", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("1", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
 }
        /// <exception cref="System.SqlSyntaxErrorException" />
        public static void Main(string[] args)
        {
            var sql = Performance.SqlBenchmarkSelect;
            var chars = sql.ToCharArray();
            var sut = new MySqlLexer(sql);
            var start = Runtime.CurrentTimeMillis();
            var end = Runtime.CurrentTimeMillis();
            for (var i = 0; i < 1; ++i)
            {
                for (; !sut.Eof();)
                {
                    sut.NextToken();
                    switch (sut.Token())
                    {
                        case MySqlToken.LiteralNumMixDigit:
                        {
                            sut.GetDecimalValue();
                            break;
                        }

                        case MySqlToken.LiteralNumPureDigit:
                        {
                            sut.GetIntegerValue();
                            break;
                        }

                        default:
                        {
                            sut.GetStringValue();
                            break;
                        }
                    }
                }
            }
            var loop = 5000000;
            sut = new MySqlLexer(sql);
            start = Runtime.CurrentTimeMillis();
            for (var i_1 = 0; i_1 < loop; ++i_1)
            {
                sut = new MySqlLexer(chars);
                for (; !sut.Eof();)
                {
                    sut.NextToken();
                    switch (sut.Token())
                    {
                        case MySqlToken.LiteralNumMixDigit:
                        {
                            sut.GetDecimalValue();
                            break;
                        }

                        case MySqlToken.LiteralNumPureDigit:
                        {
                            sut.GetIntegerValue();
                            break;
                        }

                        default:
                        {
                            sut.GetStringValue();
                            break;
                        }
                    }
                }
            }
            end = Runtime.CurrentTimeMillis();
            Console.Out.WriteLine((end - start)*1.0d/(loop/1000) + " us.");
        }
 public virtual void TestHexBit()
 {
     var sut = new MySqlLexer("0x123  ");
     Assert.AreEqual(MySqlToken.LiteralHex, sut.Token());
     Assert.AreEqual("123", new string(sut.Sql, sut.OffsetCache, sut.SizeCache));
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("0x123");
     Assert.AreEqual(MySqlToken.LiteralHex, sut.Token());
     Assert.AreEqual("123", new string(sut.Sql, sut.OffsetCache, sut.SizeCache));
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("0x123aDef");
     Assert.AreEqual(MySqlToken.LiteralHex, sut.Token());
     Assert.AreEqual("123aDef", new string(sut.Sql, sut.OffsetCache, sut.SizeCache));
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("0x0");
     Assert.AreEqual(MySqlToken.LiteralHex, sut.Token());
     Assert.AreEqual("0", new string(sut.Sql, sut.OffsetCache, sut.SizeCache));
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("0xABC");
     Assert.AreEqual(MySqlToken.LiteralHex, sut.Token());
     Assert.AreEqual("ABC", new string(sut.Sql, sut.OffsetCache, sut.SizeCache));
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("0xA01aBC");
     Assert.AreEqual(MySqlToken.LiteralHex, sut.Token());
     Assert.AreEqual("A01aBC", new string(sut.Sql, sut.OffsetCache, sut.SizeCache));
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("0x123re2  ");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("0x123re2", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("x'123'e  ");
     Assert.AreEqual(MySqlToken.LiteralHex, sut.Token());
     Assert.AreEqual("123", new string(sut.Sql, sut.OffsetCache, sut.SizeCache));
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("e", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("x'123'");
     Assert.AreEqual(MySqlToken.LiteralHex, sut.Token());
     Assert.AreEqual("123", new string(sut.Sql, sut.OffsetCache, sut.SizeCache));
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("x'102AaeF3'");
     Assert.AreEqual(MySqlToken.LiteralHex, sut.Token());
     Assert.AreEqual("102AaeF3", new string(sut.Sql, sut.OffsetCache, sut.SizeCache));
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("0b10");
     Assert.AreEqual(MySqlToken.LiteralBit, sut.Token());
     Assert.AreEqual("10", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("0b101101");
     Assert.AreEqual(MySqlToken.LiteralBit, sut.Token());
     Assert.AreEqual("101101", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("0b103  ");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("0b103", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("b'10'b  ");
     Assert.AreEqual(MySqlToken.LiteralBit, sut.Token());
     Assert.AreEqual("10", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("b", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("\r 0xabc.123;x'e'a0x1.3x'a2w'--\t0b11\n0b12*b '123' b'101'");
     Assert.AreEqual(MySqlToken.LiteralHex, sut.Token());
     Assert.AreEqual("abc", new string(sut.Sql, sut.OffsetCache, sut.SizeCache));
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralNumMixDigit, sut.Token());
     Assert.AreEqual("0.123", sut.GetDecimalValue().ToPlainString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncSemicolon, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralHex, sut.Token());
     Assert.AreEqual("e", new string(sut.Sql, sut.OffsetCache, sut.SizeCache));
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("a0x1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("3x", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'a2w'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("0b12", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpAsterisk, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("b", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'123'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralBit, sut.Token());
     Assert.AreEqual("101", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
 }
 public virtual void TestSystemVar()
 {
     var sut = new MySqlLexer("@@abc  ");
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual("abc", sut.GetStringValue());
     Assert.AreEqual("ABC", sut.GetStringValueUppercase());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@@`abc`  ");
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual("`abc`", sut.GetStringValue());
     Assert.AreEqual("`ABC`", sut.GetStringValueUppercase());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@@```abc`  ");
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual("```abc`", sut.GetStringValue());
     Assert.AreEqual("```ABC`", sut.GetStringValueUppercase());
     sut = new MySqlLexer("@@``  ");
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual("``", sut.GetStringValue());
     Assert.AreEqual("``", sut.GetStringValueUppercase());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@@`a```  ");
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual("`a```", sut.GetStringValue());
     Assert.AreEqual("`A```", sut.GetStringValueUppercase());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@@````  ");
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual("````", sut.GetStringValue());
     Assert.AreEqual("````", sut.GetStringValueUppercase());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@@`~!````@#$%^&*()``_+=-1{}[]\";:'<>,./?|\\`  ");
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual("`~!````@#$%^&*()``_+=-1{}[]\";:'<>,./?|\\`", sut
         .GetStringValue());
     Assert.AreEqual("`~!````@#$%^&*()``_+=-1{}[]\";:'<>,./?|\\`", sut
         .GetStringValueUppercase());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@@global.var1  ");
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual("global", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("var1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@@'abc'  ");
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual(string.Empty, sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'abc'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@@\"abc\"  ");
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual(string.Empty, sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'abc'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut =
         new MySqlLexer(
             "@@.  /*@@abc*/@@`abc''\"\\@@!%*&+_abcQ`//@@_1.  @@$#\n@@$var.-- @@a\t\n@@system_var:@@a`b`?");
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual(string.Empty, sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual("`abc''\"\\@@!%*&+_abcQ`", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpSlash, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpSlash, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual("_1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual("$", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual("$var", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual("system_var", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncColon, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.SysVar, sut.Token());
     Assert.AreEqual("a", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("`b`", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.QuestionMark, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
 }
Beispiel #10
0
 public virtual void TestUserDefVar()
 {
     var sut = new MySqlLexer("@abc  ");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@abc", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@abc.d  ");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@abc.d", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@abc_$.d");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@abc_$.d", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@abc_$_.");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@abc_$_.", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@''");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@'\\''");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@'\\''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@''''");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@''''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@'\"'");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@'\"'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@'\"\"'");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@'\"\"'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@'\\\"'");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@'\\\"'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@'ac\\''  ");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@'ac\\''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@'''ac\\''  ");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@'''ac\\''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@'abc'''ac\\''  ");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@'abc'''", sut.GetStringValue());
     sut = new MySqlLexer("@''abc''");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("abc", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@\"\"  ");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@\"\"", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@\"\"\"abc\"  ");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@\"\"\"abc\"", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@\"\\\"\"\"abc\"  ");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@\"\\\"\"\"abc\"", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@\"\\\"\"  ");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@\"\\\"\"", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@\"\"\"\\\"d\"  ");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@\"\"\"\\\"d\"", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@\"'\"  ");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@\"'\"", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@`` ");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@``", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@````");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@````", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@` `");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@` `", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@`abv```");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@`abv```", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@`````abc`");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@`````abc`", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@`````abc```");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@`````abc```", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@``abc");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@``", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("abc", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("@`abc`````abc```");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@`abc`````", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("abc", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("```", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer(" -- \n  @  #abc\n\r\t\"\"@\"abc\\\\''-- abc\n'''\\\"\"\"\"");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@\"abc\\\\''-- abc\n'''\\\"\"\"\"", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("/**/@a #@abc\n@.\r\t");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@a", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@.", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("  #@abc\n@\"1a_-@#!''`=\\a\"-- @\r\n@'-_1a/**/\\\"\\''/*@abc*/@`_1@\\''\"`");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@\"1a_-@#!''`=\\a\"", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@'-_1a/**/\\\"\\''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@`_1@\\''\"`", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("  /*! */@._a$ @_a.b$c.\r@1_a.$#\[email protected]_/@-- \n@_--@.[]'\"@#abc'@a,@;@~#@abc");
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@._a$", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@_a.b$c.", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@1_a.$", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@A.a_", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpSlash, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@_", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpMinus, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpMinus, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@.", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncLeftBracket, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncRightBracket, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'\"@#abc'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@a", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncComma, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncSemicolon, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.UsrVar, sut.Token());
     Assert.AreEqual("@", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpTilde, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
 }
Beispiel #11
0
 public virtual void TestString()
 {
     var sut = new MySqlLexer("''");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("'''\\''");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'\\'\\''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("\'\'\'\'\'\\''");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'\\'\\'\\''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("''''''/'abc\\''");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'\\'\\''", sut.GetStringValue());
     sut.NextToken();
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'abc\\''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("\'abc\\\'\'");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'abc\\''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("'\\\\\\\"\"\"'");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'\\\\\\\"\"\"'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("'\'\''");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'\\''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("''''");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'\\''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("'he\"\"\"llo'");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'he\"\"\"llo'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("'he'\''\'llo'");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'he\\'\\'llo'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("'\''hello'");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'\\'hello'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("\"abc'\\d\"\"ef\"");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'abc\\'\\d\"ef'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("\"abc'\\\\\"\"\"");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'abc\\'\\\\\"'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("\"\"");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("\"\\'\"");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'\\''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("\"\"\"\"");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'\"'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("\"abc\" '\\'s'");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'abc'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'\\'s'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("\"\"\"'\"");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'\"\\''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("\"\\\"\"");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'\\\"'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("\"\\\\\"");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'\\\\'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("\"   hello '''/**/#\n-- \n~=+\"\"\"\"\"");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'   hello \\'\\'\\'/**/#\n-- \n~=+\"\"'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("\r--\t\n\"abc\"");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'abc'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("N'ab\\'c'");
     Assert.AreEqual(MySqlToken.LiteralNchars, sut.Token());
     Assert.AreEqual("'ab\\'c'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("  \'abc\\\\\\'\' 'abc\\a\\'\''\"\"'/\"abc\\\"\".\"\"\"abc\"\"\"\"'\''\"n'ab\\'c'");
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'abc\\\\\\''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'abc\\a\\'\\'\"\"'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpSlash, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'abc\\\"'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.PuncDot, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralChars, sut.Token());
     Assert.AreEqual("'\"abc\"\"\\'\\'\\''", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralNchars, sut.Token());
     Assert.AreEqual("'ab\\'c'", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
 }
Beispiel #12
0
 public virtual void TestCStyleComment()
 {
     var sut = new MySqlLexer("id1 /*!id2 */ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id2", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("id1 /*! id2 */ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id2", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     sut = new MySqlLexer("id1 /*!*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     var version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40001id2*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40000id2*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id2", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!4000id2*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("4000id2", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!400001id2*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("1id2", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!400011id2*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!4000*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralNumPureDigit, sut.Token());
     Assert.AreEqual("4000", sut.GetIntegerValue().ToString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40000*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40001*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!400001*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.LiteralNumPureDigit, sut.Token());
     Assert.AreEqual("1", sut.GetIntegerValue().ToString());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40000 -- id2\n*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40000 /* id2*/*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40000/* id2*/*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40000id2*/* id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id2", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.OpAsterisk, sut.Token());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40000/*/*/id2*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id2", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40001/*/*/id2*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40000/*/*/id2*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id2", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40000/*/*/id2*/ /*!40000 id4*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id2", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id4", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40001/*/*/id2*/ /*!40000 id4*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id4", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40000/*/*/id2*/ /*!40001 id4*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id2", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40000/*/*/id2*//*!40001 id4*//*!40001 id5*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id2", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
     version = MySqlLexer.SetCStyleCommentVersion(40000);
     sut = new MySqlLexer("id1 /*!40000/*/*/id2*//*!40001 id4*//*!40000id5*/ id3");
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id1", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id2", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id5", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Identifier, sut.Token());
     Assert.AreEqual("id3", sut.GetStringValue());
     sut.NextToken();
     Assert.AreEqual(MySqlToken.Eof, sut.Token());
     MySqlLexer.SetCStyleCommentVersion(version);
 }
 public virtual void TestPrimarySystemVar()
 {
     var sql = "@@gloBal . /*dd*/ `all`";
     var lexer = new MySqlLexer(sql);
     var parser = new MySqlExprParser(lexer);
     var expr = parser.Expression();
     var output = Output2MySql(expr, sql);
     Assert.AreEqual("@@global.`all`", output);
     Assert.AreEqual(typeof (SysVarPrimary), expr.GetType());
     var sysvar = (SysVarPrimary)expr;
     Assert.AreEqual(VariableScope.Global, sysvar.Scope);
     Assert.AreEqual("`all`", sysvar.VarText);
     sql = "@@Session . /*dd*/ any";
     lexer = new MySqlLexer(sql);
     parser = new MySqlExprParser(lexer);
     expr = parser.Expression();
     output = Output2MySql(expr, sql);
     Assert.AreEqual("@@any", output);
     Assert.AreEqual(typeof (SysVarPrimary), expr.GetType());
     sysvar = (SysVarPrimary)expr;
     Assert.AreEqual(VariableScope.Session, sysvar.Scope);
     Assert.AreEqual("any", sysvar.VarText);
     sql = "@@LOCAl . /*dd*/ `usage`";
     lexer = new MySqlLexer(sql);
     parser = new MySqlExprParser(lexer);
     expr = parser.Expression();
     output = Output2MySql(expr, sql);
     Assert.AreEqual("@@`usage`", output);
     Assert.AreEqual(typeof (SysVarPrimary), expr.GetType());
     sysvar = (SysVarPrimary)expr;
     Assert.AreEqual(VariableScope.Session, sysvar.Scope);
     Assert.AreEqual("`usage`", sysvar.VarText);
     sql = "@@LOCAl . /*dd*/ `var1`";
     lexer = new MySqlLexer(sql);
     parser = new MySqlExprParser(lexer);
     expr = parser.Expression();
     output = Output2MySql(expr, sql);
     Assert.AreEqual("@@`var1`", output);
     Assert.AreEqual(typeof (SysVarPrimary), expr.GetType());
     sysvar = (SysVarPrimary)expr;
     Assert.AreEqual(VariableScope.Session, sysvar.Scope);
     Assert.AreEqual("`var1`", sysvar.VarText);
     sql = "@@var1   ,";
     lexer = new MySqlLexer(sql);
     parser = new MySqlExprParser(lexer);
     expr = parser.Expression();
     output = Output2MySql(expr, sql);
     Assert.AreEqual("@@var1", output);
     Assert.AreEqual(typeof (SysVarPrimary), expr.GetType());
     sysvar = (SysVarPrimary)expr;
     Assert.AreEqual(VariableScope.Session, sysvar.Scope);
     Assert.AreEqual("var1", sysvar.VarText);
     sql = "@@`case``1`   ,@@_";
     lexer = new MySqlLexer(sql);
     parser = new MySqlExprParser(lexer);
     expr = parser.Expression();
     output = Output2MySql(expr, sql);
     Assert.AreEqual("@@`case``1`", output);
     Assert.AreEqual(typeof (SysVarPrimary), expr.GetType());
     sysvar = (SysVarPrimary)expr;
     Assert.AreEqual(VariableScope.Session, sysvar.Scope);
     Assert.AreEqual("`case``1`", sysvar.VarText);
     lexer.NextToken();
     parser = new MySqlExprParser(lexer);
     expr = parser.Expression();
     output = Output2MySql(expr, sql);
     Assert.AreEqual("@@_", output);
     Assert.AreEqual(typeof (SysVarPrimary), expr.GetType());
     sysvar = (SysVarPrimary)expr;
     Assert.AreEqual(VariableScope.Session, sysvar.Scope);
     Assert.AreEqual("_", sysvar.VarText);
 }
 public virtual void TestExpr1()
 {
     var sql = "\"abc\" /* */  '\\'s' + id2/ id3, 123-456*(ii moD d)";
     var lexer = new MySqlLexer(sql);
     var parser = new MySqlExprParser(lexer);
     var expr = parser.Expression();
     var output = Output2MySql(expr, sql);
     Assert.AreEqual("'abc\\'s' + id2 / id3", output);
     Assert.AreEqual(typeof (ArithmeticAddExpression), expr.GetType());
     var bex = (BinaryOperatorExpression)((ArithmeticAddExpression)expr).RightOprand;
     Assert.AreEqual(typeof (ArithmeticDivideExpression), bex.GetType());
     Assert.AreEqual(typeof (Identifier), bex.RightOprand.GetType());
     lexer.NextToken();
     parser = new MySqlExprParser(lexer);
     expr = parser.Expression();
     output = Output2MySql(expr, sql);
     Assert.AreEqual("123 - 456 * (ii % d)", output);
     Assert.AreEqual(typeof (ArithmeticSubtractExpression), expr.GetType());
     sql = "(n'\"abc\"' \"abc\" /* */  '\\'s' + 1.123e1/ id3)*(.1e3-a||b)mod x'abc'&&(select 0b1001^b'0000')";
     lexer = new MySqlLexer(sql);
     parser = new MySqlExprParser(lexer);
     expr = parser.Expression();
     output = Output2MySql(expr, sql);
     Assert.AreEqual(
         "(N'\"abc\"abc\\'s' + 11.23 / id3) * (1E+2 - a OR b) % x'abc' AND (SELECT b'1001' ^ b'0000')", output);
     Assert.AreEqual(typeof (LogicalAndExpression), expr.GetType());
     bex = (BinaryOperatorExpression)((LogicalAndExpression)expr).GetOperand(0);
     Assert.AreEqual(typeof (ArithmeticModExpression), bex.GetType());
     bex = (BinaryOperatorExpression)((ArithmeticModExpression)bex).LeftOprand;
     Assert.AreEqual(typeof (ArithmeticMultiplyExpression), bex.GetType());
     bex = (BinaryOperatorExpression)((ArithmeticMultiplyExpression)bex).LeftOprand;
     Assert.AreEqual(typeof (ArithmeticAddExpression), bex.GetType());
     Assert.AreEqual(typeof (LiteralString), ((ArithmeticAddExpression)bex).LeftOprand.GetType());
     bex = (BinaryOperatorExpression)((ArithmeticAddExpression)bex).RightOprand;
     Assert.AreEqual(typeof (ArithmeticDivideExpression), bex.GetType());
     Assert.AreEqual(typeof (DmlSelectStatement), ((LogicalAndExpression)expr).GetOperand(1).GetType());
     sql = "not! ~`select` in (1,current_date,`current_date`)like `all` div a between (c&&d) and (d|e)";
     lexer = new MySqlLexer(sql);
     parser = new MySqlExprParser(lexer);
     expr = parser.Expression();
     output = Output2MySql(expr, sql);
     Assert.AreEqual(
         "NOT ! ~ `select` IN (1, CURDATE(), `current_date`) LIKE `all` DIV a BETWEEN (c AND d) AND d | e",
         output);
     Assert.AreEqual(typeof (LogicalNotExpression), expr.GetType());
     var tex = (TernaryOperatorExpression)((LogicalNotExpression)expr).Operand;
     Assert.AreEqual(typeof (BetweenAndExpression), tex.GetType());
     Assert.AreEqual(typeof (LikeExpression), tex.First.GetType());
     Assert.AreEqual(typeof (LogicalAndExpression), tex.Second.GetType());
     Assert.AreEqual(typeof (BitOrExpression), tex.Third.GetType());
     tex = (TernaryOperatorExpression)((BetweenAndExpression)tex).First;
     Assert.AreEqual(typeof (InExpression), tex.First.GetType());
     Assert.AreEqual(typeof (ArithmeticIntegerDivideExpression), tex.Second.GetType());
     bex = (InExpression)tex.First;
     Assert.AreEqual(typeof (NegativeValueExpression), bex.LeftOprand.GetType());
     Assert.AreEqual(typeof (InExpressionList), bex.RightOprand.GetType());
     UnaryOperatorExpression uex = (NegativeValueExpression)bex.LeftOprand;
     Assert.AreEqual(typeof (BitInvertExpression), uex.Operand.GetType());
     sql = " binary case ~a||b&&c^d xor e when 2>any(select a ) then 3 else 4 end is not null =a";
     lexer = new MySqlLexer(sql);
     parser = new MySqlExprParser(lexer);
     expr = parser.Expression();
     output = Output2MySql(expr, sql);
     Assert.AreEqual(
         "BINARY CASE ~ a OR b AND c ^ d XOR e WHEN 2 > ANY (SELECT a) THEN 3 ELSE 4 END IS NOT NULL = a", output);
     Assert.AreEqual(typeof (ComparisionEqualsExpression), expr.GetType());
     bex = (ComparisionEqualsExpression)expr;
     Assert.AreEqual(typeof (ComparisionIsExpression), bex.LeftOprand.GetType());
     Assert.AreEqual(typeof (Identifier), bex.RightOprand.GetType());
     var cex = (ComparisionIsExpression)bex.LeftOprand;
     Assert.AreEqual(typeof (CastBinaryExpression), cex.Operand.GetType());
     uex = (UnaryOperatorExpression)cex.Operand;
     Assert.AreEqual(typeof (CaseWhenOperatorExpression), uex.Operand.GetType());
     var cwex = (CaseWhenOperatorExpression)uex.Operand;
     Assert.AreEqual(typeof (LogicalOrExpression), cwex.Comparee.GetType());
     PolyadicOperatorExpression pex = (LogicalOrExpression)cwex.Comparee;
     Assert.AreEqual(typeof (BitInvertExpression), pex.GetOperand(0).GetType());
     Assert.AreEqual(typeof (LogicalXORExpression), pex.GetOperand(1).GetType());
     bex = (LogicalXORExpression)pex.GetOperand(1);
     Assert.AreEqual(typeof (LogicalAndExpression), bex.LeftOprand
                                                       .GetType());
     Assert.AreEqual(typeof (Identifier), bex.RightOprand.GetType());
     pex = (LogicalAndExpression)bex.LeftOprand;
     Assert.AreEqual(typeof (Identifier), pex.GetOperand(0).GetType());
     Assert.AreEqual(typeof (BitXORExpression), pex.GetOperand(1).GetType());
     sql = " !interval(a,b)<=>a>>b collate x /?+a!=@@1 or @var sounds like -(a-b) mod -(d or e)";
     lexer = new MySqlLexer(sql);
     parser = new MySqlExprParser(lexer);
     expr = parser.Expression();
     output = Output2MySql(expr, sql);
     Assert.AreEqual(
         "! INTERVAL(a, b) <=> a >> b COLLATE x / ? + a != @@1 OR @var SOUNDS LIKE - (a - b) % - (d OR e)",
         output);
     Assert.AreEqual(typeof (LogicalOrExpression), expr.GetType());
     pex = (LogicalOrExpression)expr;
     Assert.AreEqual(typeof (ComparisionNotEqualsExpression), pex.GetOperand(0).GetType());
     Assert.AreEqual(typeof (SoundsLikeExpression), pex.GetOperand(1).GetType());
     bex = (BinaryOperatorExpression)pex.GetOperand(0);
     Assert.AreEqual(typeof (ComparisionNullSafeEqualsExpression), bex.LeftOprand.GetType());
     Assert.AreEqual(typeof (SysVarPrimary), bex.RightOprand.GetType());
     bex = (BinaryOperatorExpression)bex.LeftOprand;
     Assert.AreEqual(typeof (NegativeValueExpression), bex.LeftOprand.GetType());
     Assert.AreEqual(typeof (BitShiftExpression), bex.RightOprand.
                                                      GetType());
     bex = (BinaryOperatorExpression)bex.RightOprand;
     Assert.AreEqual(typeof (Identifier), bex.LeftOprand.GetType());
     Assert.AreEqual(typeof (ArithmeticAddExpression), bex.RightOprand.GetType());
     bex = (BinaryOperatorExpression)bex.RightOprand;
     Assert.AreEqual(typeof (ArithmeticDivideExpression), bex.LeftOprand.GetType());
     Assert.AreEqual(typeof (Identifier), bex.RightOprand.GetType());
     bex = (BinaryOperatorExpression)bex.LeftOprand;
     Assert.AreEqual(typeof (CollateExpression), bex.LeftOprand.GetType());
     Assert.AreEqual(typeof (ParamMarker), bex.RightOprand.GetType());
     bex = (BinaryOperatorExpression)((LogicalOrExpression)expr).GetOperand(1);
     Assert.AreEqual(typeof (UsrDefVarPrimary), bex.LeftOprand.GetType());
     Assert.AreEqual(typeof (ArithmeticModExpression), bex.RightOprand.GetType());
     bex = (BinaryOperatorExpression)bex.RightOprand;
     Assert.AreEqual(typeof (MinusExpression), bex.LeftOprand.GetType());
     Assert.AreEqual(typeof (MinusExpression), bex.RightOprand.GetType());
     uex = (UnaryOperatorExpression)bex.LeftOprand;
     Assert.AreEqual(typeof (ArithmeticSubtractExpression), uex.Operand.GetType());
     uex = (UnaryOperatorExpression)bex.RightOprand;
     Assert.AreEqual(typeof (LogicalOrExpression), uex.Operand.GetType());
 }
Beispiel #15
0
 /// <exception cref="System.SqlSyntaxErrorException" />
 public static void Main(string[] args)
 {
     var sql =
         "   ( ( select union select union select)  as j join    (((select union (select)) as t    )   join t2 ) ,(select)as d), t3)";
     // String sql =
     // "((select) as s1, ((((   select  union select          ) as t2)) join (((t2),t4 as t))) ), t1 aS T1";
     // String sql =
     // "  (( select union select union select)  as j  ,(select)as d), t3";
     Console.Out.WriteLine(sql);
     var lexer = new MySqlLexer(sql);
     lexer.NextToken();
     var p = new SoloParser(lexer);
     var refs = p.Refs();
     Console.Out.WriteLine(refs);
 }