public bool VisitBinaryOperator( OverloadableCodeBinarySymmetricOperator binaryOperator, IEnumerable <bool> argsVisitationResults, int argsCount) { return(_specification.IsSatisfiedByBinaryOperator(binaryOperator, argsVisitationResults, argsCount)); }
public MultiArgBinaryOperatorFlexpression(OverloadableCodeBinarySymmetricOperator binaryOperator, IReadOnlyList <IFlexpression> args) { Guard.ArgCountAtLeast(args, nameof(args), 3); BinaryOperator = binaryOperator; Arguments = args; }
public static DefinableFxBinaryOperator ToDefinableFxOperator(this OverloadableCodeBinarySymmetricOperator source) { if (source == OverloadableCodeBinarySymmetricOperator.And || source == OverloadableCodeBinarySymmetricOperator.Or) { throw new ArgumentOutOfRangeException(nameof(source), $"Binary operator '{source.GetSymbol()}' ({source}) is not definable flexpression operator."); } var res = (DefinableFxBinaryOperator)source; return(res); }
/// <inheritdoc /> public string GetBinaryOperatorDescription(OverloadableCodeBinarySymmetricOperator binaryOperator) { return(binaryOperator switch { OverloadableCodeBinarySymmetricOperator.Mul => "Concatenates left and right expression with 'Anything' in between.", OverloadableCodeBinarySymmetricOperator.Div => "Concatenates left and right expression with 'next line' in between.", OverloadableCodeBinarySymmetricOperator.Mod => "Concatenates left and right expression placing 'custom pattern' in between.", OverloadableCodeBinarySymmetricOperator.Sum => "Concatenates left and right expression.", OverloadableCodeBinarySymmetricOperator.Sub => "Concatenates left and right expression, where the right one is defined as positive lookahead.", OverloadableCodeBinarySymmetricOperator.And => "Concatenates left and right expression with optional, multiple white space in between.", OverloadableCodeBinarySymmetricOperator.XOr => "Concatenates left and right expression with (non optional) white space in between.", OverloadableCodeBinarySymmetricOperator.Or => "Creates alternation from left and right expression.", _ => throw new NotSupportedException($"Operator {binaryOperator} is not supported."), });
public static CompositeSpecificationOperation ToCompositeSpecificationOperation( this OverloadableCodeBinarySymmetricOperator binaryOperator) { switch (binaryOperator) { case OverloadableCodeBinarySymmetricOperator.And: return(CompositeSpecificationOperation.And); case OverloadableCodeBinarySymmetricOperator.Or: return(CompositeSpecificationOperation.Or); case OverloadableCodeBinarySymmetricOperator.XOr: return(CompositeSpecificationOperation.XOr); default: throw new NotSupportedException($"Operator {binaryOperator} is not supported."); } }
/// <inheritdoc /> public string GetBinaryOperatorDescription(OverloadableCodeBinarySymmetricOperator binaryOperator) { var res = binaryOperator switch { OverloadableCodeBinarySymmetricOperator.And => $"Creates composite specification where the overall result is a disjunction of results of aggregated specifications.", OverloadableCodeBinarySymmetricOperator.Or => $"Creates composite specification where the overall result is a conjunction of results of aggregated specifications.", OverloadableCodeBinarySymmetricOperator.XOr => $"Creates composite specification where the overall result is a exclusive OR of results of aggregated specifications.", _ => throw new NotSupportedException($"Operator {binaryOperator} is not supported.") }; return(res); }
public static Flexpression Create( OverloadableCodeBinarySymmetricOperator binaryOperator, IFlexpression leftArgument, IFlexpression rightArgument) { if (leftArgument is BinaryOperatorFlexpression binOperator && binOperator.BinaryOperator == binaryOperator) { return(new MultiArgBinaryOperatorFlexpression(binaryOperator, new[] { binOperator.LeftArgument, binOperator.RightArgument, rightArgument })); } if (leftArgument is MultiArgBinaryOperatorFlexpression multiBinOperator && multiBinOperator.BinaryOperator == binaryOperator) { var leftArgs = multiBinOperator.Arguments; var args = new IFlexpression[leftArgs.Count + 1]; for (var idx = leftArgs.Count - 1; idx >= 0; --idx) { args[idx] = leftArgs[idx]; } args[^ 1] = rightArgument;
public static T GetOperatorResultOfHighestPrioritizedAlgebra <T>(this IDefineCodeOperatorSymmetricAlgebra <T> defaultAlgebra, OverloadableCodeBinarySymmetricOperator binaryOperator, T left, T right) where T : IDefineAlgebraicDomain <T, IDefineCodeOperatorSymmetricAlgebra <T> > { return(defaultAlgebra.GetHighestPrioritizedAlgebra(left, right).EvaluateOperatorResult(left, binaryOperator, right)); }
/// <inheritdoc /> public bool IsBinaryOperatorSupported(OverloadableCodeBinarySymmetricOperator binaryOperator) { return(((int)binaryOperator & (int)SupportedOperators) != 0); }
[Pure, MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] public FXConstraintResult IsBinaryOperatorAllowed(OverloadableCodeBinarySymmetricOperator binaryOperator, int argsCount) { return(FXConstraintResult.Allowed); }
/// <inheritdoc /> public bool IsBinaryOperatorSupported(OverloadableCodeBinarySymmetricOperator binaryOperator) { return(binaryOperator.IsOneOf(SupportedOperators)); }
[Pure] public virtual FXConstraintResult IsBinaryOperatorAllowed(OverloadableCodeBinarySymmetricOperator binaryOperator, int argsCount) { return(FXConstraintResult.Allowed); }
[DebuggerStepThrough, DebuggerHidden, MethodImpl(MethodImplOptions.AggressiveInlining)] public static void ValidateBinaryOperatorAllowed(this IFlexpressionConstraint source, OverloadableCodeBinarySymmetricOperator binaryOperator, int argsCount) { var res = source.IsBinaryOperatorAllowed(binaryOperator, argsCount); switch (res) { case FXConstraintResult.Allowed: return; case FXConstraintResult.OperationNotAllowed: throw new DomainConstraintBrokenException($"Binary operator '{binaryOperator.GetSymbol()}' ({binaryOperator}) is not allowed by domain constraint ({source.GetType().Name})."); default: throw new DomainConstraintBrokenException($"Binary operator '{binaryOperator.GetSymbol()}' ({binaryOperator}) is not allowed for the number of args={argsCount} by domain constraint ({source.GetType().Name})."); } }
public static string ToCodeRepresentation(this OverloadableCodeBinarySymmetricOperator source, object left = null, object right = null, string spaceBetweenBinOperatorAndArgument = null) { return(source.ToCodeOperator().ToCodeRepresentation(left, right, spaceBetweenBinOperatorAndArgument)); }
public static string GetSymbol(this OverloadableCodeBinarySymmetricOperator source) { return(source.ToCodeOperator().GetSymbol()); }
public static OverloadableCodeOperator ToCodeOperator(this OverloadableCodeBinarySymmetricOperator source) { return((OverloadableCodeOperator)source); }
public static bool IsNotAnyOf(this OverloadableCodeBinarySymmetricOperator source, OverloadableCodeOperators flags) { return(((int)source & (int)flags) == 0); }