public QueryExpressionNode(QueryExpressionNode left, IQueryExpressionOperator op, QueryExpressionNode right) { Left = left ?? throw new ArgumentNullException(nameof(left)); Operator = op ?? throw new ArgumentNullException(nameof(op)); Right = right; }
public static bool TryParse(ReadOnlySpan <char> span, ref int i, out IQueryExpressionOperator op) { op = null; switch (span[i]) { case '*': i++; op = Multiplication; return(true); case '/': i++; op = Division; return(true); case '%': i++; op = Modulus; return(true); case '+': i++; op = Addition; return(true); case '-': i++; op = Subtraction; return(true); case '=': if (i + 1 >= span.Length) { return(false); } if (span[i + 1] == '=') { i += 2; op = EqualTo; return(true); } break; case '!': if (i + 1 >= span.Length) { return(false); } if (span[i + 1] == '=') { i += 2; op = NotEqualTo; return(true); } break; case '<': if (i + 1 < span.Length && span[i + 1] == '=') { i += 2; op = LessThanOrEqualTo; return(true); } i++; op = LessThan; return(true); case '>': if (i + 1 < span.Length && span[i + 1] == '=') { i += 2; op = GreaterThanOrEqualTo; return(true); } i++; op = GreaterThan; return(true); case '&': if (i + 1 >= span.Length) { return(false); } if (span[i + 1] == '&') { i += 2; op = And; return(true); } break; case '|': if (i + 1 >= span.Length) { return(false); } if (span[i + 1] == '|') { i += 2; op = Or; return(true); } break; } return(false); }