コード例 #1
0
        public void Test_can_parse_parenthesized_expression_for_binary_expression_for_two_parenthesized_expressions()
        {
            CmsqlParser cmsqlParser =
                CmsqlParserFactory.CreateParserForQuery(
                    "((jon != 'stark' and john = 'snow') or (arya = 'stark' and sansa = 'stark'))");

            CmsqlParser.ParenthesizedExpressionContext parseTree =
                (CmsqlParser.ParenthesizedExpressionContext)cmsqlParser.expression();

            ExpressionVisitor          visitor          = new ExpressionVisitor();
            CmsqlQueryBinaryExpression binaryExpression = (CmsqlQueryBinaryExpression)visitor.VisitParenthesizedExpression(parseTree);

            binaryExpression.LeftExpression.Should().BeOfType <CmsqlQueryBinaryExpression>();
            binaryExpression.LeftExpression.Should().NotBeNull();
            binaryExpression.RightExpression.Should().BeOfType <CmsqlQueryBinaryExpression>();
            binaryExpression.RightExpression.Should().NotBeNull();

            CmsqlQueryBinaryExpression leftParenthesizedBinaryExpression = (CmsqlQueryBinaryExpression)binaryExpression.LeftExpression;

            leftParenthesizedBinaryExpression.LeftExpression.Should().BeOfType <CmsqlQueryCondition>();
            leftParenthesizedBinaryExpression.LeftExpression.Should().NotBeNull();
            leftParenthesizedBinaryExpression.RightExpression.Should().BeOfType <CmsqlQueryCondition>();
            leftParenthesizedBinaryExpression.RightExpression.Should().NotBeNull();

            CmsqlQueryBinaryExpression rightParenthesizedBinaryExpression = (CmsqlQueryBinaryExpression)binaryExpression.RightExpression;

            rightParenthesizedBinaryExpression.LeftExpression.Should().BeOfType <CmsqlQueryCondition>();
            rightParenthesizedBinaryExpression.LeftExpression.Should().NotBeNull();
            rightParenthesizedBinaryExpression.RightExpression.Should().BeOfType <CmsqlQueryCondition>();
            rightParenthesizedBinaryExpression.RightExpression.Should().NotBeNull();
        }
コード例 #2
0
        public void Test_can_parse_parenthesized_expression_containing_condition_expression()
        {
            CmsqlParser cmsqlParser = CmsqlParserFactory.CreateParserForQuery("(foo != 'bar')");

            CmsqlParser.ParenthesizedExpressionContext parseTree =
                (CmsqlParser.ParenthesizedExpressionContext)cmsqlParser.expression();

            ExpressionVisitor     visitor    = new ExpressionVisitor();
            ICmsqlQueryExpression expression = visitor.VisitParenthesizedExpression(parseTree);

            expression.Should().BeOfType <CmsqlQueryCondition>();
            expression.Should().NotBeNull();
        }
コード例 #3
0
        public void Test_can_parse_parenthesized_expression_for_binary_expression()
        {
            CmsqlParser cmsqlParser = CmsqlParserFactory.CreateParserForQuery("(foo != 'bar' and bar = 'foo')");

            CmsqlParser.ParenthesizedExpressionContext parseTree =
                (CmsqlParser.ParenthesizedExpressionContext)cmsqlParser.expression();

            ExpressionVisitor          visitor          = new ExpressionVisitor();
            CmsqlQueryBinaryExpression binaryExpression = (CmsqlQueryBinaryExpression)visitor.VisitParenthesizedExpression(parseTree);

            binaryExpression.LeftExpression.Should().BeOfType <CmsqlQueryCondition>();
            binaryExpression.LeftExpression.Should().NotBeNull();
            binaryExpression.RightExpression.Should().BeOfType <CmsqlQueryCondition>();
            binaryExpression.RightExpression.Should().NotBeNull();
        }
コード例 #4
0
        public override ICmsqlQueryExpression VisitParenthesizedExpression(CmsqlParser.ParenthesizedExpressionContext context)
        {
            ExpressionVisitor expressionVisitor = new ExpressionVisitor();

            return(context.expression().Accept(expressionVisitor));
        }