예제 #1
0
 public override void VisitAfter(ExtractFuncExpr expr)
 {
     if (IsPlaceHolderExpr(expr.Argument))
     {
         expr.Argument = Place((PlaceHolderExpr)expr.Argument);
     }
 }
예제 #2
0
        public override void ExitExtract_function(MiniSqlParserParser.Extract_functionContext context)
        {
            var comments         = this.GetComments(context);
            var datetimeComments = this.GetComments(context.datetimeField());

            comments.InsertRange(2, datetimeComments);

            Expr arg     = null;
            bool isComma = false;

            if (context.expr() != null)
            {
                arg     = (Expr)_stack.Pop();
                isComma = context.K_FROM() == null;
            }
            DateTimeField dt = DateTimeField.Day;
            var           datetimeContext = context.datetimeField();

            if (datetimeContext.K_DAY() != null)
            {
                dt = DateTimeField.Day;
            }
            else if (datetimeContext.K_YEAR() != null)
            {
                dt = DateTimeField.Year;
            }
            else if (datetimeContext.K_MONTH() != null)
            {
                dt = DateTimeField.Month;
            }
            else if (datetimeContext.K_HOUR() != null)
            {
                dt = DateTimeField.Hour;
            }
            else if (datetimeContext.K_MINUTE() != null)
            {
                dt = DateTimeField.Minute;
            }
            else if (datetimeContext.K_SECOND() != null)
            {
                dt = DateTimeField.Second;
            }
            else
            {
                throw new CannotBuildASTException("Undefined DateTimeField is used in EXTRACT function");
            }
            var name = context.K_EXTRACT().GetText();

            var node = new ExtractFuncExpr(name, dt, isComma, arg, comments);

            _stack.Push(node);
        }
        public override void VisitAfter(ExtractFuncExpr expr)
        {
            Expr arg = (Expr)_stack.Pop();

            if (object.ReferenceEquals(expr.Argument, arg))
            {
                _stack.Push(expr);
                return;
            }

            var node = new ExtractFuncExpr(expr.Name
                                           , expr.DateTimeField
                                           , expr.SeparatorIsComma, arg);

            _stack.Push(node);
        }
예제 #4
0
 virtual public void VisitOnSeparator(ExtractFuncExpr expr, int offset)
 {
 }
예제 #5
0
 virtual public void VisitAfter(ExtractFuncExpr expr)
 {
 }
예제 #6
0
 virtual public void VisitBefore(ExtractFuncExpr expr)
 {
 }
예제 #7
0
 public void VisitOnSeparator(ExtractFuncExpr expr, int offset)
 {
     _visitor.VisitOnSeparator(expr, offset);
 }
예제 #8
0
 public void VisitAfter(ExtractFuncExpr expr)
 {
     _visitor.VisitAfter(expr);
 }
예제 #9
0
 public void VisitBefore(ExtractFuncExpr expr)
 {
     _visitor.VisitBefore(expr);
 }