/// <summary> Adds the specified operator to the respective appendable sets regarding domainKind, associativity and precedence. </summary> public static void Add(Notion @operator, DomainKind domainKind, Associativity associativity, Set precedenceSet) { Contract.Requires(@operator != null); Contract.RequiresEnumIsDefined(domainKind); Contract.Requires(domainKind != DomainKind.Operand); Contract.RequiresEnumIsDefined(associativity); Contract.Requires(precedenceSet != null); Contract.Requires(ReferenceEquals(precedenceSet.Workspace, @operator.Workspace)); Contract.Requires(Precedences.Contains(precedenceSet)); Contract.Requires(AllAppendableSetsRelationToLinearNotions.All(linearAppendableSet => !linearAppendableSet.Contains(@operator))); Contract.Requires(precedenceSet.IsAppendable); var workspace = @operator.Workspace; precedenceSet.Append(@operator); switch (domainKind) { case DomainKind.UnaryPrefix: UnaryPreOperators.Append(@operator); break; case DomainKind.UnaryPostfix: UnaryPostOperators.Append(@operator); break; case DomainKind.Binary: BinaryOperators.Append(@operator); break; case DomainKind.Nullary: NullaryOperators.Append(@operator); break; case DomainKind.Operand: default: throw new Exception(); } switch (associativity) { case Associativity.Left: LeftAssociativeOperators.Append(@operator); break; case Associativity.Right: RightAssociativeOperators.Append(@operator); break; case Associativity.Undefined: UnassociativeOperators.Append(@operator); break; case Associativity.Associative: AssociativeOperators.Append(@operator); break; default: throw new Exception(); } }
public LinearAPSet(Workspace workspace, Associativity associativity) : base(DefaultNotions.Operators, $"{associativity.ToName()}associative operators", appendable: true) { Contract.Requires(DefaultNotions.Operators != null); Contract.Requires(workspace != null); Contract.RequiresEnumIsDefined(associativity); this.Associativity = associativity; this.PrecedenceComparisonToken = defaultPrecedenceToken; this.DomainKind = defaultDomainKind; }
public FlatDomain(T value) { state = DomainKind.Normal; Value = value; }
FlatDomain(DomainKind state) { this.state = state; Value = default(T); }
/// <summary> Adds the specified operator to the respective appendable sets regarding domainKind and associativity, and creates a new precedence token at the specified index in precedences. </summary> /// <param name="index"> The index in workspace.Precedences at which to insert a new EqualPrecedenceOperators set in which to insert the specified operator. Hence 0 is highest precedence (except for operands, which have -1 precedence). </param> public static void Add(Notion @operator, DomainKind domainKind, Associativity associativity, int index = 0) { Contract.Requires(@operator != null); Contract.Requires(0 <= index && index <= PrecedenceElements.Count); if (index != 0) throw new NotImplementedException();//this has to do with the non-set nature of the precedences, since it's actually a list so we need to distinguish insertion from appendage Set newPrecedenceContainer = new LinearAPSet(@operator.Workspace, (IComparable)0);// Precedences.DefinitionSet.Clone("binary |", appendable: true, isConstant: true); Precedences.Append(newPrecedenceContainer); Add(@operator, domainKind, associativity, newPrecedenceContainer); }
public static LinearAPSet Create(Signature signature, DomainKind domainKind) { Contract.Requires(signature != null); Contract.Requires(domainKind != Nullary); return new LinearAPSet(domainKind, signature, isConstant: true); }
public LinearAPSet(Workspace workspace, IComparable precedenceComparisonToken) : base(DefaultNotions.Operators, $"operators with precedence {precedenceComparisonToken}", appendable: true) { Contract.Requires(DefaultNotions.Operators != null); Contract.Requires(workspace != null); Contract.Requires(precedenceComparisonToken != NoPrecedence); PrecedenceComparisonToken = precedenceComparisonToken; this.Associativity = defaultAssociativity; this.DomainKind = defaultDomainKind; }
/// <summary> Allows to clone instances of this type. </summary> protected LinearAPSet(LinearAPSet toClone, string description, bool? appendable) : base(toClone, description, appendable) { this.Associativity = toClone.Associativity; this.PrecedenceComparisonToken = toClone.PrecedenceComparisonToken; this.DomainKind = toClone.DomainKind; }
private LinearAPSet(DomainKind domainKind, Set signature, bool isConstant) : base(DefaultNotions.SetDefinition, signature.ToSingletonReadOnlyList<ISet>(), $"{domainKind} operators (any AP)", appendable: true) { Contract.Requires(domainKind.IsAnyOf(UnaryPostfix, UnaryPrefix, Nullary, Binary, Unary)); this.DomainKind = domainKind; this.PrecedenceComparisonToken = defaultPrecedenceToken; this.Associativity = defaultAssociativity; }