Exemple #1
0
        internal void ParseExpression_OperatorPrecedence_MultiplicationLowerInTreeAdditionHigher()
        {
            var expectedAst = new AstBinaryExpression
            {
                Operator = CmdTokenKind.Plus,
                Lhs      = new AstNumberExpression
                {
                    Value = "2"
                },
                Rhs = new AstBinaryExpression
                {
                    Lhs = new AstNumberExpression
                    {
                        Value = "2"
                    },
                    Rhs = new AstNumberExpression
                    {
                        Value = "2"
                    },
                    Operator = CmdTokenKind.Star
                }
            };

            AstAssert.Expression(expectedAst, "2+2*2");
        }
Exemple #2
0
        internal void ParseExpression_OddNumberOfAddition()
        {
            var expectedAst = new AstBinaryExpression
            {
                Operator = CmdTokenKind.Plus,
                Lhs      = new AstBinaryExpression
                {
                    Lhs = new AstNumberExpression
                    {
                        Value = "1"
                    },
                    Rhs = new AstNumberExpression
                    {
                        Value = "2"
                    },
                    Operator = CmdTokenKind.Plus
                },
                Rhs = new AstNumberExpression
                {
                    Value = "3"
                }
            };

            AstAssert.Expression(expectedAst, "1+2+3");
        }
Exemple #3
0
        internal void ParseExpression_OddNumberOfMultiplication()
        {
            var expectedAst = new AstBinaryExpression
            {
                Operator = CmdTokenKind.Star,
                Lhs      = new AstBinaryExpression
                {
                    Lhs = new AstNumberExpression
                    {
                        Value = "1"
                    },
                    Rhs = new AstNumberExpression
                    {
                        Value = "2"
                    },
                    Operator = CmdTokenKind.Star
                },
                Rhs = new AstNumberExpression
                {
                    Value = "3"
                },
            };

            AstAssert.Expression(expectedAst, "1*2*3");
        }
Exemple #4
0
        internal void ParseExpression_ParenthesisPrecedence_AdditionInParenthesisLowerInAstTreeThanMultiplication()
        {
            var expectedAst = new AstBinaryExpression
            {
                Operator = CmdTokenKind.Star,
                Lhs      = new AstBinaryExpression
                {
                    Lhs = new AstNumberExpression
                    {
                        Value = "1"
                    },
                    Rhs = new AstNumberExpression
                    {
                        Value = "2"
                    },
                    Operator = CmdTokenKind.Plus
                },
                Rhs = new AstNumberExpression
                {
                    Value = "3"
                },
            };

            AstAssert.Expression(expectedAst, "(1+2)*3");
        }
Exemple #5
0
        internal void ParseExpression_UnaryExpression_SupportForPlusOperator()
        {
            var expectedAst = new AstUnaryExpression
            {
                Operator   = CmdTokenKind.Plus,
                Expression = new AstNumberExpression
                {
                    Value = "6"
                }
            };

            AstAssert.Expression(expectedAst, "+6");
        }
Exemple #6
0
        internal void ParseExpression_DivisionSupport()
        {
            var expectedAst = new AstBinaryExpression
            {
                Operator = CmdTokenKind.Slash,
                Lhs      = new AstNumberExpression
                {
                    Value = "1"
                },
                Rhs = new AstNumberExpression
                {
                    Value = "2"
                }
            };

            AstAssert.Expression(expectedAst, "1/2");
        }
Exemple #7
0
        internal void ParseExpression_SubtractionSupport()
        {
            var expectedAst = new AstBinaryExpression
            {
                Operator = CmdTokenKind.Minus,
                Lhs      = new AstNumberExpression
                {
                    Value = "1"
                },
                Rhs = new AstNumberExpression
                {
                    Value = "2"
                }
            };

            AstAssert.Expression(expectedAst, "1-2");
        }
Exemple #8
0
        internal void ParseExpression_UnaryExpression_Precedence()
        {
            var expectedAst = new AstBinaryExpression
            {
                Operator = CmdTokenKind.Star,
                Lhs      = new AstUnaryExpression
                {
                    Operator   = CmdTokenKind.Minus,
                    Expression = new AstNumberExpression
                    {
                        Value = "6"
                    }
                },
                Rhs = new AstNumberExpression
                {
                    Value = "2"
                },
            };

            AstAssert.Expression(expectedAst, "-6*2");
        }
Exemple #9
0
        public void ParseExpression_BooleanExpression_SupportFor()
        {
            var expectedAst = new AstBinaryExpression
            {
                Operator = CmdTokenKind.GreaterThan,
                Lhs      = new AstNumberExpression {
                    Value = "3"
                },
                Rhs = new AstBinaryExpression
                {
                    Operator = CmdTokenKind.Plus,
                    Lhs      = new AstNumberExpression {
                        Value = "1"
                    },
                    Rhs = new AstNumberExpression {
                        Value = "2"
                    },
                }
            };

            AstAssert.Expression(expectedAst, "3>1+2");
        }
        public void ParseStatement_Insert()
        {
            var expectedAst = new AstInsertStatement()
            {
                Location = new AstLocation()
                {
                    Value = "soltysdb_kv"
                },
                Values = new AstValue(new[]
                {
                    new AstExpression()
                    {
                        Value = "aaa"
                    },
                    new AstExpression()
                    {
                        Value = "bbb"
                    }
                })
            };

            AstAssert.Statement(expectedAst, "INSERT INTO soltysdb_kv VALUES (aaa,bbb)");
        }
Exemple #11
0
        public void ParseFactor_ParsingFunctionWithArgumentsCall()
        {
            var expectedArguments = new AstExpression[]
            {
                new AstNumberExpression
                {
                    Value = "1"
                },
                new AstBinaryExpression
                {
                    Operator = CmdTokenKind.Plus,
                    Lhs      = new AstNumberExpression {
                        Value = "2"
                    },
                    Rhs = new AstNumberExpression {
                        Value = "3"
                    },
                }
            };

            var expectedAst = new AstFunctionCallExpression("ExampleCall", expectedArguments);

            AstAssert.Factor(expectedAst, "ExampleCall(1, 2+3)");
        }
Exemple #12
0
        public void ParseFactor_ParsingFunctionWithoutArgumentsCall()
        {
            var expectedAst = new AstFunctionCallExpression("GetKeys");

            AstAssert.Factor(expectedAst, "GetKeys()");
        }