コード例 #1
0
        public override IExpressionNode VisitLogicalExpression([NotNull] QLanguageParser.LogicalExpressionContext context)
        {
            var logicalEntityContext = context.logicalEntity();

            if (logicalEntityContext != null)
            {
                return(VisitLogicalEntity(logicalEntityContext));
            }


            var logicalExpressionContext = context.logicalExpression();

            if (logicalExpressionContext != null && logicalExpressionContext.Length == 1)
            {
                return(VisitLogicalExpression(logicalExpressionContext[0]));
            }

            var comparisonExpressionContext = context.comparisonExpression();

            if (comparisonExpressionContext != null)
            {
                return(new ComparisonExpressionVisitor().VisitComparisonExpression(comparisonExpressionContext));
            }

            var left  = VisitLogicalExpression(context.LEFT);
            var opr   = LogicalExpressionNode.ParseLogicalOperator(context.OPR.Text);
            var right = VisitLogicalExpression(context.RIGHT);

            return(new LogicalExpressionNode(Location.FromContext(context), left, opr, right));;
        }
コード例 #2
0
        public override IExpressionNode VisitLogicalExpression(LogicalExpressionContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("Context can't be null");
            }

            var logicalEntityContext = context.logicalEntity();

            if (logicalEntityContext != null)
            {
                return(VisitLogicalEntity(logicalEntityContext));
            }

            var logicalExpressionContext = context.logicalExpression();

            if (logicalExpressionContext != null && logicalExpressionContext.Length == 1)
            {
                return(VisitLogicalExpression(logicalExpressionContext[0]));
            }

            var comparisonExpressionContext = context.comparisonExpression();

            if (comparisonExpressionContext != null)
            {
                return(new ComparisonExpressionVisitor().VisitComparisonExpression(comparisonExpressionContext));
            }

            var left  = VisitLogicalExpression(context.LEFT);
            var opr   = LogicalExpressionNode.ParseLogicalOperator(context.OPR.Text);
            var right = VisitLogicalExpression(context.RIGHT);

            return(new LogicalExpressionNode(Location.FromContext(context), left, opr, right));;
        }