Esempio n. 1
0
        private PredicateSegment CreateInSegment(SqlServerCommandParser.PredicateContext context)
        {
            ColumnSegment         column = (ColumnSegment)Visit(context.bitExpr(0));
            PredicateBracketValue predicateBracketValue = CreateBracketValue(context);

            return(new PredicateSegment(context.Start.StartIndex, context.Stop.StopIndex, column, new PredicateInRightValue(predicateBracketValue, GetExpressionSegments(context))));
        }
Esempio n. 2
0
        private PredicateSegment CreateBetweenSegment(SqlServerCommandParser.PredicateContext context)
        {
            ColumnSegment      column  = (ColumnSegment)Visit(context.bitExpr(0));
            IExpressionSegment between = (IExpressionSegment)Visit(context.bitExpr(1));
            IExpressionSegment and     = (IExpressionSegment)Visit(context.predicate());

            return(new PredicateSegment(context.Start.StartIndex, context.Stop.StopIndex, column, new PredicateBetweenRightValue(between, and)));
        }
Esempio n. 3
0
        private PredicateBracketValue CreateBracketValue(SqlServerCommandParser.PredicateContext context)
        {
            PredicateLeftBracketValue predicateLeftBracketValue = null != context.subquery()
                ? new PredicateLeftBracketValue(context.subquery().LP_().Symbol.StartIndex, context.subquery().LP_().Symbol.StopIndex)
                : new PredicateLeftBracketValue(context.LP_().Symbol.StartIndex, context.LP_().Symbol.StopIndex);
            PredicateRightBracketValue predicateRightBracketValue = null != context.subquery()
                ? new PredicateRightBracketValue(context.subquery().RP_().Symbol.StartIndex, context.subquery().RP_().Symbol.StopIndex)
                : new PredicateRightBracketValue(context.RP_().Symbol.StartIndex, context.RP_().Symbol.StopIndex);

            return(new PredicateBracketValue(predicateLeftBracketValue, predicateRightBracketValue));
        }
Esempio n. 4
0
        private ICollection <IExpressionSegment> GetExpressionSegments(SqlServerCommandParser.PredicateContext context)
        {
            ICollection <IExpressionSegment> result = new LinkedList <IExpressionSegment>();

            if (null != context.subquery())
            {
                SqlServerCommandParser.SubqueryContext subquery = context.subquery();
                result.Add(new SubQueryExpressionSegment(new SubQuerySegment(subquery.Start.StartIndex, subquery.Stop.StopIndex, (SelectCommand)Visit(context.subquery()))));
                return(result);
            }

            foreach (var expr in context.expr())
            {
                result.Add((IExpressionSegment)Visit(expr));
            }

            return(result);
        }
Esempio n. 5
0
        public override IASTNode VisitPredicate(SqlServerCommandParser.PredicateContext context)
        {
            if (null != context.IN() && null == context.NOT())
            {
                return(CreateInSegment(context));
            }

            if (null != context.BETWEEN() && null == context.NOT())
            {
                return(CreateBetweenSegment(context));
            }

            if (1 == context.children.Count)
            {
                return(Visit(context.bitExpr(0)));
            }

            return(VisitRemainPredicate(context));
        }
Esempio n. 6
0
        private IASTNode VisitRemainPredicate(SqlServerCommandParser.PredicateContext context)
        {
            foreach (var bitExpr in context.bitExpr())
            {
                Visit(bitExpr);
            }

            foreach (var expr in context.expr())
            {
                Visit(expr);
            }

            foreach (var simpleExpr in context.simpleExpr())
            {
                Visit(simpleExpr);
            }

            if (null != context.predicate())
            {
                Visit(context.predicate());
            }

            return(new CommonExpressionSegment(context.Start.StartIndex, context.Stop.StopIndex, context.GetText()));
        }