public static Flexpression Create( IFlexpression content, long min, long max) { return(new QuantifierFlexpression(content, min, max)); }
public static bool Satisfies(this IFlexpression source, IFlexpressionSpecification flexpressionSpecification) { var visitor = new SpecificationToVisitorAdapter(flexpressionSpecification); var satisfied = source.AcceptVisitor(visitor); return(satisfied); }
public QuantifierFlexpression(IFlexpression content, long min, long max) { Content = content ?? throw new ArgumentNullException(nameof(content)); if (Content is QuantifierFlexpression quantifier) { Content = quantifier.Content; min = quantifier.Min * Min; max = quantifier.Max * Max; } if (min < 0) { throw new ArgumentException($"Min value {min} is smaller than 0.", nameof(min)); } if (max < 0) { throw new ArgumentException($"Max value {max} is smaller than 0.", nameof(max)); } if (max < min) { throw new ArgumentException($"Max value {max} is smaller than min value {min}.", nameof(max)); } Min = min; Max = max; }
/// <summary> /// Initializes a new instance of the <see cref="GotoWrapper" /> class. /// </summary> /// <param name="flexpression">The flexpression to retrieve the list of <see cref="LabelTarget"/>s from.</param> /// <param name="labelName">The name of the label.</param> /// <exception cref="ArgumentNullException">When the <paramref name="flexpression"/> is null, the exception is thrown.</exception> /// <exception cref="ArgumentException">When the <paramref name="labelName"/> is null, empty, or just whitespace, the exception is thrown.</exception> public GotoWrapper(IFlexpression flexpression, string labelName) { Debug.Assert((flexpression != null), "The flexpression argument cannot be null."); Debug.Assert(!string.IsNullOrWhiteSpace(labelName), "The labelName argument cannot be null, empty, or just whitespace."); this.flexpression = flexpression; this.labelName = labelName; }
/// <summary> /// Initializes a new instance of the <see cref="GotoWrapper" /> class. /// </summary> /// <param name="flexpression">The flexpression to retrieve the list of <see cref="LabelTarget"/>s from.</param> /// <param name="labelName">The name of the label.</param> /// <exception cref="ArgumentNullException">When the <paramref name="flexpression"/> is null, the exception is thrown.</exception> /// <exception cref="ArgumentException">When the <paramref name="labelName"/> is null, empty, or just whitespace, the exception is thrown.</exception> public GotoWrapper(IFlexpression flexpression, string labelName) { Debug.Assert((flexpression != null), "The flexpression argument cannot be null."); Debug.Assert(!string.IsNullOrWhiteSpace(labelName), "The labelName argument cannot be null, empty, or just whitespace."); this.flexpression = flexpression; this.labelName = labelName; }
/// <summary> /// Creates a new instance of the <see cref="Block<TParent>"/>. /// </summary> /// <param name="parent">The parent to return to once the block has been ended.</param> /// <param name="lookupParent">The lookup parent is used to have the <see cref="Block<TParent>"/> return to <paramref name="parent"/>, but pull its lookups from another (used to improve fluent syntax).</param> /// <param name="allowRethrow">Indicates whether or not this block allows rethrow.</param> /// <param name="implicitVariables">A collection of implicit variables to be used as valid, when looking for variables.</param> /// <exception cref="ArgumentNullException">When the <paramref name="parent"/> is null, the exception is thrown.</exception> internal Block(TParent parent, IFlexpression lookupParent = null, bool allowRethrow = false, IEnumerable <ParameterExpression> implicitVariables = null) { Debug.Assert((parent != null), "The parent argument cannot be null."); this.parent = parent; this.lookupParent = lookupParent ?? parent; this.allowRethrow = allowRethrow; this.implicitVariables = implicitVariables; this.lstExpressions = new List <IExpressionWrapper>(); this.variables = new List <ParameterExpression>(); this.Variables = variables.AsReadOnly(); }
/// <summary> /// Creates an else if block of the if block. /// </summary> /// <param name="test">The test to perform for the else if block.</param> /// <returns>The <see cref="Block<TParent>"/> of the new else if block.</returns> /// <exception cref="InvalidOperationException">When an else/else if was already set for this block, the exception is thrown.</exception> private Block <If <TParent> > ElseIfSafe(Expression test) { if (this.expressionFalse != null) { throw new InvalidOperationException("An else statement already exists for the current context."); } var elseIf = new If <TParent>(this.parent, test); this.expressionFalse = elseIf; return(elseIf.expressionTrue); }
public Flexpression DefineGroup(string groupName, IFlexpression content) { var group = _groupsDefinitionsByName.GetExistingValueOrNew( groupName, pName => new GroupFlexpressionDefinition(pName, AutoFreezingValue.CreateUndefined <IFlexpression>())); if (content != null) { group.ContentContainer.Set(content); } return(group); }
public void AssignDefaultBody(IFlexpression defaultBody) { if (defaultBody == null) { throw new ArgumentNullException("defaultBody"); } if (this.defaultBody != null) { throw new InvalidOperationException("Only one default statement is allowed per switch statement."); } this.defaultBody = defaultBody; }
public virtual bool Equals(IFlexpression other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(LocalId.Equals(other.LocalId)); }
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 UnaryOperatorFlexpression Create(OverloadableCodeUnarySymmetricOperator unaryOperator, IFlexpression argument) { return(new UnaryOperatorFlexpression(unaryOperator, argument)); }
public UnaryOperatorFlexpression(OverloadableCodeUnarySymmetricOperator unaryOperator, IFlexpression argument) { UnaryOperator = unaryOperator; Argument = argument; }
public static Flexpression Create( IFlexpression content, long count) { return(new QuantifierFlexpression(content, count, count)); }
public bool VisitCustom(IFlexpression customFlexpression) { return(_specification.IsSatisfiedByCustom(customFlexpression)); }
public static bool IsSatisfiedBy(this IFlexpressionSpecification flexpressionSpecification, IFlexpression flexpression) { var visitor = new SpecificationToVisitorAdapter(flexpressionSpecification); var satisfied = flexpression.AcceptVisitor(visitor); return(satisfied); }