示例#1
0
        public override void ExitGeneric_function(MiniSqlParserParser.Generic_functionContext context)
        {
            var comments = this.GetComments(context.function_name().qualified_schema_name());

            comments.AddRange(this.GetComments(context.function_name()));
            comments.AddRange(this.GetComments(context));
            Identifier serverName   = null;
            Identifier databaseName = null;
            Identifier schemaName   = null;

            if (context.function_name().qualified_schema_name() != null)
            {
                serverName   = this.GetIdentifier(context.function_name().qualified_schema_name().s);
                databaseName = this.GetIdentifier(context.function_name().qualified_schema_name().d);
                schemaName   = this.GetIdentifier(context.function_name().qualified_schema_name().n);
            }
            var   name      = this.GetIdentifier(context.function_name().identifier());
            Exprs arguments = null;

            if (context.exprs() != null)
            {
                arguments = (Exprs)_stack.Pop();
            }
            _stack.Push(new FuncExpr(serverName, databaseName, schemaName, name, arguments, comments));
        }
示例#2
0
        public override void ExitWindow_function(MiniSqlParserParser.Window_functionContext context)
        {
            var comments = this.GetComments(context.function_name().qualified_schema_name());

            comments.AddRange(this.GetComments(context.function_name()));
            comments.AddRange(this.GetComments(context));
            Identifier serverName   = null;
            Identifier databaseName = null;
            Identifier schemaName   = null;

            if (context.function_name().qualified_schema_name() != null)
            {
                serverName   = this.GetIdentifier(context.function_name().qualified_schema_name().s);
                databaseName = this.GetIdentifier(context.function_name().qualified_schema_name().d);
                schemaName   = this.GetIdentifier(context.function_name().qualified_schema_name().n);
            }
            var name = this.GetIdentifier(context.function_name().identifier());

            QuantifierType quantifier;

            if (context.K_DISTINCT() != null)
            {
                quantifier = QuantifierType.Distinct;
            }
            else if (context.K_ALL() != null)
            {
                quantifier = QuantifierType.All;
            }
            else
            {
                quantifier = QuantifierType.None;
            }

            var         hasWildcard = context.STAR() != null;
            var         orderBy     = (OrderBy)_stack.Pop();
            PartitionBy partitionBy = null;

            if (context.partitionBy_clause() != null)
            {
                partitionBy = (PartitionBy)_stack.Pop();
            }

            Exprs arguments = null;

            if (context.exprs() != null)
            {
                arguments = (Exprs)_stack.Pop();
            }

            _stack.Push(new WindowFuncExpr(serverName
                                           , databaseName
                                           , schemaName
                                           , name
                                           , quantifier
                                           , hasWildcard
                                           , arguments
                                           , partitionBy
                                           , orderBy
                                           , comments));
        }
示例#3
0
 public override void VisitAfter(Exprs exprs)
 {
     for (int i = 0; i < exprs.Count; ++i)
     {
         if (IsPlaceHolderExpr(exprs[i]))
         {
             exprs[i] = Place((PlaceHolderExpr)exprs[i]);
         }
     }
 }
示例#4
0
 public CallStmt(Identifier serverName
                 , Identifier databaseName
                 , Identifier schemaName
                 , Identifier name
                 , Exprs arguments)
 {
     this.Comments     = new Comments(4);
     this.ServerName   = serverName;
     this.DataBaseName = databaseName;
     this.SchemaName   = schemaName;
     this.Name         = name;
     this.Arguments    = arguments;
 }
示例#5
0
 internal CallStmt(Identifier serverName
                   , Identifier databaseName
                   , Identifier schemaName
                   , Identifier name
                   , Exprs arguments
                   , Comments comments)
 {
     this.Comments  = comments;
     _serverName    = serverName;
     _dataBaseName  = databaseName;
     _schemaName    = schemaName;
     _name          = name;
     this.Arguments = arguments;
 }
        public override void VisitAfter(Exprs exprs)
        {
            bool isReferenceEqual = true;

            var exprList = new List <Expr>();

            for (var i = exprs.Count - 1; i >= 0; --i)
            {
                var expr = (Expr)_stack.Pop();
                exprList.Insert(0, expr);
                isReferenceEqual = isReferenceEqual && object.ReferenceEquals(exprs[i], expr);
            }

            if (isReferenceEqual)
            {
                _stack.Push(exprs);
                return;
            }

            var node = new Exprs(exprList, exprs.Comments.Clone());

            _stack.Push(node);
        }
        public override void VisitAfter(WindowFuncExpr expr)
        {
            OrderBy     orderBy     = (OrderBy)_stack.Pop();
            PartitionBy partitionBy = null;

            if (expr.PartitionBy != null)
            {
                partitionBy = (PartitionBy)_stack.Pop();
            }
            Exprs arg = null;

            if (expr.Arguments != null)
            {
                arg = (Exprs)_stack.Pop();
            }

            if (object.ReferenceEquals(expr.Arguments, arg) &&
                object.ReferenceEquals(expr.PartitionBy, partitionBy) &&
                object.ReferenceEquals(expr.OrderBy, orderBy))
            {
                _stack.Push(expr);
                return;
            }

            var node = new WindowFuncExpr(expr.ServerName
                                          , expr.DataBaseName
                                          , expr.SchemaName
                                          , expr.Name
                                          , expr.Quantifier
                                          , expr.HasWildcard
                                          , arg
                                          , partitionBy
                                          , orderBy
                                          , expr.Comments.Clone());

            _stack.Push(node);
        }
        public override void VisitAfter(FuncExpr expr)
        {
            Exprs args = null;

            if (expr.Arguments != null)
            {
                args = (Exprs)_stack.Pop();
            }

            if (object.ReferenceEquals(expr.Arguments, args))
            {
                _stack.Push(expr);
                return;
            }

            var node = new FuncExpr(expr.ServerName
                                    , expr.DataBaseName
                                    , expr.SchemaName
                                    , expr.Name
                                    , args
                                    , expr.Comments.Clone());

            _stack.Push(node);
        }
示例#9
0
 virtual public void VisitAfter(Exprs exprs)
 {
 }
示例#10
0
 virtual public void VisitBefore(Exprs exprs)
 {
 }
示例#11
0
 virtual public void VisitOnSeparator(Exprs exprs, int offset, int i)
 {
 }
 public void VisitAfter(Exprs exprs)
 {
     _visitor.VisitAfter(exprs);
 }
 public void VisitBefore(Exprs exprs)
 {
     _visitor.VisitBefore(exprs);
 }
 public void VisitOnSeparator(Exprs exprs, int offset, int i)
 {
     _visitor.VisitOnSeparator(exprs, offset, i);
 }
示例#15
0
 internal GroupBy(Exprs terms, Comments comments)
     : this(terms) {
     this.Comments = comments;
 }
示例#16
0
 public CallStmt(Identifier name
                 , Exprs arguments)
     : this(null, null, null, name, arguments)
 {
 }