Example #1
0
    private static ICondition?ReadBetweenCondition(IConditionKeyword operand, bool negated, IWordReader reader, List <string> messages)
    {
        var min = ReadNextKeyword(reader, messages);

        if (min is null)
        {
            return(null);
        }

        if (!ReadExpectingNotBeTheEnd(reader, messages))
        {
            return(null);
        }

        if (reader.WordType != WordType.And)
        {
            messages.Add(string.Format(BetweenWithoutAnd, reader.Word));
            return(null);
        }

        var max = ReadNextKeyword(reader, messages);

        if (max is null)
        {
            return(null);
        }

        if (negated)
        {
            return(new NotBetweenCondition(operand, min, max));
        }

        return(new BetweenCondition(operand, min, max));
    }
Example #2
0
    private static ICondition?ReadNullCondition(IConditionKeyword operand, IWordReader reader, List <string> messages)
    {
        if (!ReadExpectingNotBeTheEnd(reader, messages))
        {
            return(null);
        }

        if (reader.WordType == WordType.Null)
        {
            return(new IsNullCondition(operand));
        }

        if (reader.WordType != WordType.Not)
        {
            messages.Add(string.Format(InvalidTokenAfterIs, reader.Word));
            return(null);
        }

        if (!ReadExpectingNotBeTheEnd(reader, messages))
        {
            return(null);
        }

        if (reader.WordType == WordType.Null)
        {
            return(new IsNotNullCondition(operand));
        }

        messages.Add(string.Format(InvalidTokenAfterIsNot, reader.Word));
        return(null);
    }
Example #3
0
    private static ICondition?ReadInCondition(IConditionKeyword operand, bool negated, IWordReader reader, List <string> messages)
    {
        if (!ReadExpectingNotBeTheEnd(reader, messages))
        {
            return(null);
        }

        if (reader.WordType != WordType.OpenParenthesys)
        {
            messages.Add(string.Format(InvalidTokenAfterIn, reader.Word));
            return(null);
        }

        var values = new List <IConditionKeyword>();
        IConditionKeyword?value;

        for (; ;)
        {
            value = ReadNextKeyword(reader, messages);
            if (value is null)
            {
                return(null);
            }
            values.Add(value);

            if (!ReadExpectingNotBeTheEnd(reader, messages))
            {
                return(null);
            }

            if (reader.WordType == WordType.CloseParenthesys)
            {
                break;
            }

            if (reader.WordType != WordType.Comma)
            {
                messages.Add(string.Format(InvalidTokenAfterInValue, reader.Word));
                return(null);
            }
        }

        if (negated)
        {
            return(new NotInCondition(operand, values));
        }

        return(new InCondition(operand, values));
    }
Example #4
0
    private static ICondition?ReadOperator(
        IWordReader reader,
        List <string> messages,
        IConditionKeyword left,
        Func <IConditionKeyword, IConditionKeyword, ICondition> factory
        )
    {
        var right = ReadNextKeyword(reader, messages);

        if (right is null)
        {
            return(null);
        }
        return(factory.Invoke(left, right));
    }
Example #5
0
    private static ICondition?ReadNotOperator(
        IWordReader reader,
        List <string> messages,
        IConditionKeyword left
        )
    {
        if (!ReadExpectingNotBeTheEnd(reader, messages))
        {
            return(null);
        }

        if (reader.WordType == WordType.In)
        {
            return(ReadInCondition(left, true, reader, messages));
        }

        if (reader.WordType == WordType.Between)
        {
            return(ReadBetweenCondition(left, true, reader, messages));
        }

        messages.Add(string.Format(InvalidTokenAfterNot, reader.Word));
        return(null);
    }
Example #6
0
 public BetweenCondition(IConditionKeyword operand, IConditionKeyword min, IConditionKeyword max)
 {
     Operand = operand;
     Min     = min;
     Max     = max;
 }
Example #7
0
 public ComparisonConditionBase(IConditionKeyword left, IConditionKeyword right)
 {
     Left  = left;
     Right = right;
 }
Example #8
0
 public NotEqualsToCondition(IConditionKeyword left, IConditionKeyword right) : base(left, right)
 {
 }
Example #9
0
 public IsNotNullCondition(IConditionKeyword operand) => Operand = operand;
Example #10
0
 public InCondition(IConditionKeyword operand, IEnumerable <IConditionKeyword> values)
 {
     Operand = operand;
     Values  = values;
 }
Example #11
0
 public GreaterThanCondition(IConditionKeyword left, IConditionKeyword right) : base(left, right)
 {
 }
Example #12
0
 public EqualOrLowerThanCondition(IConditionKeyword left, IConditionKeyword right) : base(left, right)
 {
 }