/// <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); } }
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); } }