static void ParseFile(string filePath) { var fileLoader = new FileLoader(); var content = File.ReadAllText(filePath, GetFileEncoding(filePath)); var parser = Parser.FromText(content, filePath, CompilerDefines.CreateStandard(), fileLoader); var parseTree = parser.ParseRule(RuleType.Goal); }
static void Main(string[] args) { ParseFile(@"H:\Work\Unit.pas"); var matches = new List<string>(); var fileLoader = new FileLoader(); var path = @"E:\Work"; foreach (var filePath in Directory.EnumerateFiles(path, "*.pas", SearchOption.TopDirectoryOnly)) { try { var content = File.ReadAllText(filePath, GetFileEncoding(filePath)); var parser = Parser.FromText(content, filePath, CompilerDefines.CreateStandard(), fileLoader); var parseTree = parser.ParseRule(RuleType.Goal); } catch(Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Error in " + filePath); Console.ResetColor(); Directory.CreateDirectory("Errors"); File.WriteAllText(Path.Combine("Errors", Path.GetFileName(filePath) + ".txt"), ex.ToString()); } } }