private static DMPreprocessor Preprocess(List <string> files) { DMPreprocessor preprocessor = new DMPreprocessor(true, !Settings.SuppressUnimplementedWarnings); if (!Settings.NoStandard) { string compilerDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string dmStandardDirectory = Path.Combine(compilerDirectory ?? string.Empty, "DMStandard"); if (!File.Exists(Path.Combine(dmStandardDirectory, "_Standard.dm"))) { Error(new CompilerError(Location.Unknown, "DMStandard not found.")); return(null); } preprocessor.IncludeFile(dmStandardDirectory, "_Standard.dm"); } VerbosePrint("Preprocessing"); foreach (string file in files) { string directoryPath = Path.GetDirectoryName(file); string fileName = Path.GetFileName(file); preprocessor.IncludeFile(directoryPath, fileName); } return(preprocessor); }
private static List <DreamMapJson> ConvertMaps(List <string> mapPaths) { List <DreamMapJson> maps = new(); foreach (string mapPath in mapPaths) { VerbosePrint($"Converting map {mapPath}"); DMPreprocessor preprocessor = new DMPreprocessor(false, !Settings.SuppressUnimplementedWarnings); preprocessor.IncludeFile(Path.GetDirectoryName(mapPath), Path.GetFileName(mapPath)); DMLexer lexer = new DMLexer(mapPath, preprocessor.GetResult()); DMMParser parser = new DMMParser(lexer); DreamMapJson map = parser.ParseMap(); if (parser.Errors.Count > 0) { foreach (CompilerError error in parser.Errors) { Error(error); } continue; } if (parser.Warnings.Count > 0) { foreach (CompilerWarning warning in parser.Warnings) { Warning(warning); } } maps.Add(map); } return(maps); }