Example #1
0
 public InterpreterType(TrsTypeDefinitionTermBase sourceTypeDefinition, InterpreterType parentNode = null)
 {
     this.ParentNode = parentNode;
       this.CurrentNode = sourceTypeDefinition;
       if (sourceTypeDefinition is TrsTypeDefinitionTerm)
     ArgumentMatchedTypes.AddRange(((TrsTypeDefinitionTerm)sourceTypeDefinition).ArgumentTypes.Select(arg => new InterpreterType(arg,this)));
       else if (sourceTypeDefinition is TrsTypeDefinitionAcTerm)
     AcArgumentMatchedTypes = ((TrsTypeDefinitionAcTerm)sourceTypeDefinition).OnfArgumentTypes.ToDictionary(arg => new InterpreterType(arg.Term), arg => arg.Cardinality);
 }
Example #2
0
 public override TrsTypeDefinitionTermBase CreateCopyAndReplaceSubTermRefEquals(TrsTypeDefinitionTermBase termToReplace, TrsTypeDefinitionTermBase replacementTerm)
 {
     if (object.ReferenceEquals(this, termToReplace)) return replacementTerm;
       else return new TrsTypeDefinitionAcTerm(TermName,
     OnfArgumentTypes.Select(arg => new TrsTypeDefinitionOnfAcTermArgument
     {
       Term = arg.Term.CreateCopyAndReplaceSubTermRefEquals(termToReplace, replacementTerm),
       Cardinality = arg.Cardinality
     }));
 }
Example #3
0
 /// <summary>
 /// Creates a copy of this term, replacing the termToReplace with the replacementTerm.
 /// Term equality is defined using Object.ReferenceEquals.
 /// </summary>
 /// <returns></returns>
 public abstract TrsTypeDefinitionTermBase CreateCopyAndReplaceSubTermRefEquals(TrsTypeDefinitionTermBase termToReplace, TrsTypeDefinitionTermBase replacementTerm);
 public override TrsTypeDefinitionTermBase CreateCopyAndReplaceSubTermRefEquals(TrsTypeDefinitionTermBase termToReplace, TrsTypeDefinitionTermBase replacementTerm)
 {
     if (object.ReferenceEquals(this, termToReplace)) return replacementTerm;
       else return new TrsTypeDefinitionTypeName(TypeName);
 }
Example #5
0
 public override TrsTypeDefinitionTermBase CreateCopyAndReplaceSubTermRefEquals(TrsTypeDefinitionTermBase termToReplace, TrsTypeDefinitionTermBase replacementTerm)
 {
     if (object.ReferenceEquals(this, termToReplace)) return replacementTerm;
       else return new TrsTypeDefinitionTerm(TermName, ArgumentTypes.Select(arg => arg.CreateCopyAndReplaceSubTermRefEquals(termToReplace, replacementTerm)).ToList());
 }
 public override TrsTypeDefinitionTermBase CreateCopyAndReplaceSubTermRefEquals(TrsTypeDefinitionTermBase termToReplace, TrsTypeDefinitionTermBase replacementTerm)
 {
     if (object.ReferenceEquals(this, termToReplace))
     {
         return(replacementTerm);
     }
     else
     {
         return(new TrsTypeDefinitionVariable(VariableName));
     }
 }
 public override TrsTypeDefinitionTermBase CreateCopyAndReplaceSubTermRefEquals(TrsTypeDefinitionTermBase termToReplace, TrsTypeDefinitionTermBase replacementTerm)
 {
     if (object.ReferenceEquals(this, termToReplace))
     {
         return(replacementTerm);
     }
     else
     {
         return(new TrsTypeDefinitionAcTerm(TermName,
                                            OnfArgumentTypes.Select(arg => new TrsTypeDefinitionOnfAcTermArgument
         {
             Term = arg.Term.CreateCopyAndReplaceSubTermRefEquals(termToReplace, replacementTerm),
             Cardinality = arg.Cardinality
         })));
     }
 }
Example #8
0
 public override TrsTypeDefinitionTermBase CreateCopyAndReplaceSubTermRefEquals(TrsTypeDefinitionTermBase termToReplace, TrsTypeDefinitionTermBase replacementTerm)
 {
     if (object.ReferenceEquals(this, termToReplace))
     {
         return(replacementTerm);
     }
     else
     {
         return(new TrsTypeDefinitionTerm(TermName, ArgumentTypes.Select(arg => arg.CreateCopyAndReplaceSubTermRefEquals(termToReplace, replacementTerm)).ToList()));
     }
 }
 /// <summary>
 /// Creates a copy of this term, replacing the termToReplace with the replacementTerm.
 /// Term equality is defined using Object.ReferenceEquals.
 /// </summary>
 /// <returns></returns>
 public abstract TrsTypeDefinitionTermBase CreateCopyAndReplaceSubTermRefEquals(TrsTypeDefinitionTermBase termToReplace, TrsTypeDefinitionTermBase replacementTerm);
Example #10
0
 /// <summary>
 /// Updates transition function to add variable and atom mappings for the base types.
 /// This is neccesary to avoid an infinite number of type definitions.
 /// </summary>
 private void AddDynamicStates(TrsTypeDefinitionTermBase termIn)
 {
     foreach (TrsTypeDefinitionTermBase targetSymbol in termIn.GetAllAtoms().Cast<TrsTypeDefinitionTermBase>().Concat(termIn.GetAllVariables()))
       {
     TrsTypeDefinitionTypeName nextStateTypeName = null;
     if (targetSymbol is TrsTypeDefinitionNumber) nextStateTypeName = allNumbers;
     else if (targetSymbol is TrsTypeDefinitionString) nextStateTypeName = allStrings;
     else if (targetSymbol is TrsTypeDefinitionConstant) nextStateTypeName = allConstants;
     else if (targetSymbol is TrsTypeDefinitionVariable) nextStateTypeName = allVariables;
     else throw new ArgumentOutOfRangeException("To collective type for " + targetSymbol.GetType().FullName);
     List<TrsTypeDefinitionTypeName> nextStates = null;
     if (!transitionFunction.TryGetValue(targetSymbol, out nextStates))
       transitionFunction.Add(targetSymbol, nextStates = new List<TrsTypeDefinitionTypeName>());
     nextStates.Add(nextStateTypeName);
       }
 }