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)); }
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); }
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)); }
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)); }
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); }
public BetweenCondition(IConditionKeyword operand, IConditionKeyword min, IConditionKeyword max) { Operand = operand; Min = min; Max = max; }
public ComparisonConditionBase(IConditionKeyword left, IConditionKeyword right) { Left = left; Right = right; }
public NotEqualsToCondition(IConditionKeyword left, IConditionKeyword right) : base(left, right) { }
public IsNotNullCondition(IConditionKeyword operand) => Operand = operand;
public InCondition(IConditionKeyword operand, IEnumerable <IConditionKeyword> values) { Operand = operand; Values = values; }
public GreaterThanCondition(IConditionKeyword left, IConditionKeyword right) : base(left, right) { }
public EqualOrLowerThanCondition(IConditionKeyword left, IConditionKeyword right) : base(left, right) { }