示例#1
0
 private static void CompileExpression(IrGroup irGroup, ExpressionNode expression)
 {
     foreach (var arg in expression.Arguments)
     {
         switch (expression.ExpressionType)
         {
             case ExpressionType.Seconds:
                 CompileSecondsArgument(irGroup, arg);
                 break;
             case ExpressionType.Minutes:
                 CompileMinutesArgument(irGroup, arg);
                 break;
             case ExpressionType.Hours:
                 CompileHoursArgument(irGroup, arg);
                 break;
             case ExpressionType.DaysOfWeek:
                 CompileDaysOfWeekArgument(irGroup, arg);
                 break;
             case ExpressionType.DaysOfMonth:
                 CompileDaysOfMonthArgument(irGroup, arg);
                 break;
             case ExpressionType.DaysOfYear:
                 CompileDaysOfYearArgument(irGroup, arg);
                 break;
             case ExpressionType.Dates:
                 CompileDateArgument(irGroup, arg);
                 break;
             default:
                 throw new Exception("Expression type " + expression.ExpressionType + " not supported by the schyntax compiler." + SchyntaxException.PLEASE_REPORT_BUG_MSG);
         }
     }
 }
示例#2
0
        private ExpressionNode ParseExpression()
        {
            var nameTok = Expect(TokenType.ExpressionName);
            var type = (ExpressionType)Enum.Parse(typeof(ExpressionType), nameTok.Value);
            var exp = new ExpressionNode(type);
            exp.AddToken(Expect(TokenType.OpenParen));

            while (true)
            {
                exp.AddArgument(ParseArgument(type));

                if (IsNext(TokenType.CloseParen))
                {
                    break;
                }

                if (IsNext(TokenType.Comma)) // optional comma
                {
                    exp.AddToken(Advance());
                }
            }

            exp.AddToken(Expect(TokenType.CloseParen));
            return exp;
        }
示例#3
0
        private void Expression(ExpressionNode expression)
        {
            if (expression.Arguments.Count == 0)
                throw new SchyntaxParseException("Expression has no arguments.", Input, expression.Index);

            foreach (var arg in expression.Arguments)
            {
                if (arg.HasInterval && arg.IntervalValue == 0)
                {
                    throw new SchyntaxParseException("\"%0\" is not a valid interval. If your intention was to include all " +
                        ExpressionTypeToHumanString(expression.ExpressionType) +
                        " use the wildcard operator \"*\" instead of an interval", Input, arg.IntervalTokenIndex);
                }

                var validator = GetValidator(expression.ExpressionType);

                if (arg.IsWildcard)
                {
                    if (arg.IsExclusion && !arg.HasInterval)
                    {
                        throw new SchyntaxParseException(
                            "Wildcards can't be excluded with the ! operator, except when part of an interval (using %)",
                            Input, arg.Index);
                    }
                }
                else
                {
                    if (arg.Range == null || arg.Range.Start == null)
                    {
                        throw new SchyntaxParseException("Expected a value or range.", Input, arg.Index);
                    }

                    Range(expression.ExpressionType, arg.Range, validator);
                }

                if (arg.HasInterval)
                {
                    validator(ExpressionType.IntervalValue, arg.Interval);
                }
            }
        }
示例#4
0
 public void AddExpression(ExpressionNode exp)
 {
     _expressions.Add(exp);
 }