ASTTree ReadFileToTree(string codeFolder, string command) { //while (true) //{ // Console.WriteLine("a"); // Thread.Sleep(1000); //} string code = ""; string[] lines = System.IO.File.ReadAllLines(@"" + codeFolder + "/" + command + ".txt"); //linesOut = lines; // //string filename = ""; //Thread thread = new Thread(() => ReadFile(codeFolder, command)); //thread.Start(); // foreach (string line in lines) { // if an included module if (line.IndexOf("#include") >= 0) { try { string moduleName = line.Substring(line.IndexOf("<") + 1, line.IndexOf(">") - line.IndexOf("<") - 1); MISC.ConsoleWriteLine("Included: " + moduleName, ConsoleColor.Green); try { string[] modulelines = System.IO.File.ReadAllLines(@"" + moduleFolder + "/" + moduleName); foreach (string moduleline in modulelines) { code += moduleline + "\n"; MISC.ConsoleWriteLine(moduleline, ConsoleColor.Yellow); } } catch { MISC.ConsoleWriteLine("Invalid include adress: " + moduleFolder + "/" + moduleName, ConsoleColor.Red); } } catch { MISC.ConsoleWriteLine("Invalid include: " + line, ConsoleColor.Red); } } else { code += line + "\n"; Console.WriteLine(line); } } ASTTree t = new ASTTree(code); return(t); }
ASTTree ReadFileToTree(string codeFolder, string command) { string code = ""; string[] lines = System.IO.File.ReadAllLines(@"" + codeFolder + "/" + command + ".txt"); foreach (string line in lines) { // if an included module if (line.IndexOf("#include") >= 0) { try { string moduleName = line.Substring(line.IndexOf("<") + 1, line.IndexOf(">") - line.IndexOf("<") - 1); MISC.ConsoleWriteLine("Included: " + moduleName, ConsoleColor.Green); try { string[] modulelines = System.IO.File.ReadAllLines(@"" + moduleFolder + "/" + moduleName); foreach (string moduleline in modulelines) { code += moduleline + "\n"; MISC.ConsoleWriteLine(moduleline, ConsoleColor.Yellow); } } catch { MISC.ConsoleWriteLine("Invalid include adress: " + moduleFolder + "/" + moduleName, ConsoleColor.Red); } } catch { MISC.ConsoleWriteLine("Invalid include: " + line, ConsoleColor.Red); } } else { code += line + "\n"; Console.WriteLine(line); } } ASTTree t = new ASTTree(code, @"" + codeFolder + "/" + command + ".txt"); return(t); }