// TODO The following methods are based on the ones from DafnyPipeline/DafnyMain.cs. // It could be convenient to adapt them in the main-repo so location info could be extracted. public bool TryParseIncludesOfModule(ModuleDecl module, BuiltIns builtIns, ErrorReporter errorReporter) { var errors = new Errors(errorReporter); // Issue #40: // A HashSet must not be used here since equals treats A included by B not equal to A included by C. // In contrast, the compareTo-Method treats them as the same. var resolvedIncludes = new SortedSet <Include>(); var dependencyMap = new DependencyMap(); dependencyMap.AddIncludes(resolvedIncludes); bool newIncludeParsed = true; while (newIncludeParsed) { newIncludeParsed = false; // Parser.Parse appears to modify the include list; thus, we create a copy to avoid concurrent modifications. var moduleIncludes = new List <Include>(((LiteralModuleDecl)module).ModuleDef.Includes); dependencyMap.AddIncludes(moduleIncludes); foreach (var include in moduleIncludes) { bool isNewInclude = resolvedIncludes.Add(include); if (isNewInclude) { newIncludeParsed = true; if (!TryParseInclude(include, module, builtIns, errorReporter, errors)) { return(false); } } } } return(true); }