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(); }
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(); }
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(); }
public override ICmsqlQueryExpression VisitParenthesizedExpression(CmsqlParser.ParenthesizedExpressionContext context) { ExpressionVisitor expressionVisitor = new ExpressionVisitor(); return(context.expression().Accept(expressionVisitor)); }