Beispiel #1
0
        public void TestSelectClause1()
        {
            Position  pos   = new Position("select", query);
            Error     error = new Error(pos);
            StringLex lex   = new StringLex(query, error);

            List <string> tokens = new List <string>();

            while (!lex.EOF())
            {
                lex.InSymbol();

                tokens.Add(lex.token.ToString());
            }

            string[] L = tokens.ToArray();

            string code   = string.Join("|", L);
            string result = "SELECT|TOP|1000|%|%|physloc|%|%|AS|[|%|%|physloc|%|%|]|,|0|AS|[|%|%|RowId|%|%|]|,|*|FROM|Northwind|.|dbo|.|[|Products|]";

            Debug.Assert(code == result, "error");
        }
Beispiel #2
0
    public static void Main()
    {
        string input = "-154216";
        Lexer  L     = new IntLexer(input);

        try
        {
            int res = L.Save();
            System.Console.WriteLine(res);
        }
        catch (LexerException e)
        {
            System.Console.WriteLine(e.Message);
        }


        input = "a1231dfs3";
        L     = new Identificator(input);
        try
        {
            L.Parse();
        }
        catch (LexerException e)
        {
            System.Console.WriteLine(e.Message);
        }


        input = "-013";
        L     = new IntStartsNot0(input);
        try
        {
            L.Parse();
        }
        catch (LexerException e)
        {
            System.Console.WriteLine(e.Message);
        }


        input = "a4f4h2";
        L     = new LetDig(input);
        try
        {
            L.Parse();
        }
        catch (LexerException e)
        {
            System.Console.WriteLine(e.Message);
        }


        input = "sfdsf,werw,hkkh;u";
        L     = new StrWithMarks(input);
        try
        {
            L.SaveList();
        }
        catch (LexerException e)
        {
            System.Console.WriteLine(e.Message);
        }


        input = "wer   wrw yyyrtyr      er";
        L     = new StrWithSpaces(input);
        try
        {
            L.SaveList();
        }
        catch (LexerException e)
        {
            System.Console.WriteLine(e.Message);
        }


        input = "a21ef4r55yu";
        L     = new GroupLetDig(input);
        try
        {
            string s = L.SaveStr();
            System.Console.WriteLine(s);
        }
        catch (LexerException e)
        {
            System.Console.WriteLine(e.Message);
        }


        input = "242.2342342";
        L     = new DoubleLex(input);
        try
        {
            double d = L.SaveDouble();
            System.Console.WriteLine(d);
        }
        catch (LexerException e)
        {
            System.Console.WriteLine(e.Message);
        }

        input = "'строка'";
        L     = new StringLex(input);
        try
        {
            L.Parse();
        }
        catch (LexerException e)
        {
            System.Console.WriteLine(e.Message);
        }

        input = "/*выаы*/";
        L     = new Comment(input);
        try
        {
            L.Parse();
        }
        catch (LexerException e)
        {
            System.Console.WriteLine(e.Message);
        }

        System.Console.Read();
    }
Beispiel #3
0
 public SqlCode(string sql)
 {
     this.pos   = new Position("unknown sql module", sql);
     this.error = new Error(pos);
     this.lex   = new StringLex(sql, error);
 }