public static int Main(string[] args) { DateTime ldt = DateTime.Now; PascalABCCompiler.StringResourcesLanguage.LoadDefaultConfig(); Compiler = new PascalABCCompiler.Compiler(null, null); StringResourcesLanguage.CurrentLanguageName = StringResourcesLanguage.AccessibleLanguages[0]; //Console.WriteLine("OK {0}ms", (DateTime.Now - ldt).TotalMilliseconds); ldt = DateTime.Now; //ShowConnectedParsers(); if (args.Length == 0) { Console.WriteLine(StringResourcesGet("COMMANDLINEISABSENT")); return 2; } FileName = args[0]; if (!File.Exists(FileName)) { Console.WriteLine(StringResourcesGet("FILEISABSENT{0}"),FileName); return 3; } outputType = CompilerOptions.OutputType.ConsoleApplicaton; CompilerOptions co = new CompilerOptions(FileName, outputType); if (args.Length==1) co.OutputDirectory = ""; else co.OutputDirectory = args[1]; co.Rebuild = false; co.Debug = true; co.UseDllForSystemUnits = false; bool success = true; if (Compiler.Compile(co) != null) Console.WriteLine("OK"); else { Console.WriteLine(StringResourcesGet("COMPILEERRORS")); success = false; } // Console.WriteLine("OK {0}ms", (DateTime.Now - ldt).TotalMilliseconds); ///// for (int i = 0; i < Compiler.ErrorsList.Count; i++) { if (Compiler.ErrorsList[i] is LocatedError) { SourceLocation sl; if ((sl = (Compiler.ErrorsList[i] as LocatedError).SourceLocation) != null) Console.WriteLine(string.Format("[{0},{1}] {2}: {3}", sl.BeginPosition.Line, sl.BeginPosition.Column, Path.GetFileName(sl.FileName), Compiler.ErrorsList[i].Message)); else Console.WriteLine(Compiler.ErrorsList[i]); } break; // выйти после первой же ошибки } if (success) return 0; else return 1; }
public static void SetOutType(string type) { type = type.ToLower(); if (type == "dll") { outputType = CompilerOptions.OutputType.ClassLibrary; } if (type == "exe") { outputType = CompilerOptions.OutputType.ConsoleApplicaton; } if (type == "winexe") { outputType = CompilerOptions.OutputType.WindowsApplication; } }
public static int Main(string[] args) { PascalABCCompiler.StringResourcesLanguage.LoadDefaultConfig(); if (args.Length == 1 && args[0] == "commandmode") { return (new CommandConsoleCompiler()).Run(); } else StringResourcesLanguage.CurrentLanguageName = StringResourcesLanguage.AccessibleLanguages[0]; for (int i = 0; i < Console.BufferWidth-1; i++) BlankString += " "; Console.ForegroundColor = ConsoleColor.White; OutputDirectory=""; Console.Title = StringResourcesGet("STARTING"); Reset(); Console.Title = Compiler.Banner; //Console.CursorLeft = (Console.BufferWidth - Compiler.Banner.Length) / 2; //Console.WriteLine(Compiler.Banner); short_output = args.Length != 1; if (args.Length >= 1) { FileName = args[0]; } if (args.Length >= 2) if (args[1] == "/rebuildnodebug") { Rebuild = true; Compiler.InternalDebug.IncludeDebugInfoInPCU = false; short_output = false; DetailOut = true; } else if (args[1] == "/rebuild") { Rebuild = true; short_output = false; DetailOut = true; } else TagertFileName = args[1]; outputType = CompilerOptions.OutputType.ConsoleApplicaton; if (args.Length >= 3) SetOutType(args[2]); ShowConnectedParsers(); ShowConnectedConversions(); if (args.Length >= 1) { return CompileAssembly(FileName, outputType, true); } ExecuteCommand("?"); while (true) { Console.WriteLine(); string Dir = Environment.CurrentDirectory; int dleng = 25; Console.ForegroundColor = ConsoleColor.Gray; if (Dir.Length > dleng) Dir = string.Format("...{0}>", Dir.Substring(Dir.Length - dleng)); else Dir = string.Format("{0}>", Dir); Console.Write(Dir); Console.ForegroundColor = ConsoleColor.Green; if (!ExecuteCommand(Console.ReadLine())) { Console.ForegroundColor = ConsoleColor.Gray; Console.BackgroundColor = ConsoleColor.Black; return 0; } } }
public static void SetOutType(string type) { type = type.ToLower(); if (type == "dll") outputType = CompilerOptions.OutputType.ClassLibrary; if (type == "exe") outputType = CompilerOptions.OutputType.ConsoleApplicaton; if (type == "winexe") outputType = CompilerOptions.OutputType.WindowsApplication; }
public static int Main(string[] args) { DateTime ldt = DateTime.Now; PascalABCCompiler.StringResourcesLanguage.LoadDefaultConfig(); Compiler = new PascalABCCompiler.Compiler(null, null); StringResourcesLanguage.CurrentLanguageName = StringResourcesLanguage.AccessibleLanguages[0]; //Console.WriteLine("OK {0}ms", (DateTime.Now - ldt).TotalMilliseconds); ldt = DateTime.Now; //ShowConnectedParsers(); if (args.Length == 0) { Console.WriteLine(StringResourcesGet("COMMANDLINEISABSENT")); return(2); } FileName = args[0]; if (!File.Exists(FileName)) { Console.WriteLine(StringResourcesGet("FILEISABSENT{0}"), FileName); return(3); } outputType = CompilerOptions.OutputType.ConsoleApplicaton; CompilerOptions co = new CompilerOptions(FileName, outputType); if (FileName.ToLower().EndsWith(".pabcproj")) { co.ProjectCompiled = true; } if (args.Length == 1) { co.OutputDirectory = ""; } else { co.OutputDirectory = args[1]; } co.Rebuild = false; co.Debug = true; co.UseDllForSystemUnits = false; bool success = true; if (Compiler.Compile(co) != null) { Console.WriteLine("OK"); } else { Console.WriteLine(StringResourcesGet("COMPILEERRORS")); success = false; } // Console.WriteLine("OK {0}ms", (DateTime.Now - ldt).TotalMilliseconds); ///// for (int i = 0; i < Compiler.ErrorsList.Count; i++) { if (Compiler.ErrorsList[i] is LocatedError) { SourceLocation sl; if ((sl = (Compiler.ErrorsList[i] as LocatedError).SourceLocation) != null) { Console.WriteLine(string.Format("[{0},{1}] {2}: {3}", sl.BeginPosition.Line, sl.BeginPosition.Column, Path.GetFileName(sl.FileName), Compiler.ErrorsList[i].Message)); } else { Console.WriteLine(Compiler.ErrorsList[i]); } } break; // выйти после первой же ошибки } if (success) { return(0); } else { return(1); } }
public static int Main(string[] initialArgs) { var args = initialArgs.ToList(); if (args.Remove("/noconsole")) { NoConsole = true; } PascalABCCompiler.StringResourcesLanguage.LoadDefaultConfig(); if (args.Count == 1 && args[0] == "commandmode") { return((new CommandConsoleCompiler()).Run()); } else { StringResourcesLanguage.CurrentLanguageName = StringResourcesLanguage.AccessibleLanguages[0]; } for (int i = 0; i < ConsoleBufferWidth - 1; i++) { BlankString += " "; } Console.ForegroundColor = ConsoleColor.White; OutputDirectory = ""; Console.Title = StringResourcesGet("STARTING"); Reset(); Console.Title = Compiler.Banner; //Console.CursorLeft = (Console.BufferWidth - Compiler.Banner.Length) / 2; //Console.WriteLine(Compiler.Banner); short_output = args.Count != 1; if (args.Count >= 1) { FileName = args[0]; } if (args.Count >= 2) { if (args[1] == "/rebuildnodebug") { Rebuild = true; Compiler.InternalDebug.IncludeDebugInfoInPCU = false; short_output = false; DetailOut = true; } else if (args[1] == "/rebuild") { Rebuild = true; short_output = false; DetailOut = true; } else { TagertFileName = args[1]; } } outputType = CompilerOptions.OutputType.ConsoleApplicaton; if (args.Count >= 3) { SetOutType(args[2]); } ShowConnectedParsers(); ShowConnectedConversions(); if (args.Count >= 1) { return(CompileAssembly(FileName, outputType, true)); } ExecuteCommand("?"); while (true) { Console.WriteLine(); string Dir = Environment.CurrentDirectory; int dleng = 25; Console.ForegroundColor = ConsoleColor.Gray; if (Dir.Length > dleng) { Dir = string.Format("...{0}>", Dir.Substring(Dir.Length - dleng)); } else { Dir = string.Format("{0}>", Dir); } Console.Write(Dir); Console.ForegroundColor = ConsoleColor.Green; if (!ExecuteCommand(Console.ReadLine())) { Console.ForegroundColor = ConsoleColor.Gray; Console.BackgroundColor = ConsoleColor.Black; return(0); } } }
public static int CompileAssembly(string FileName, CompilerOptions.OutputType outputType, bool PauseIfError) { if (RestartOnNewCompile) { Reset(); } StartTime = DateTime.Now; Console.ForegroundColor = ConsoleColor.White; string msg = string.Format(StringResourcesGet("COMPILING_ASSEMBLY{0}"), System.IO.Path.GetFileName(FileName)); if (short_output) { ClearLine(); Console.Write(msg); } else { Console.WriteLine(msg); } DateTime ldt = DateTime.Now; CompilerOptions co = new CompilerOptions(FileName, outputType); if (FileName.ToLower().EndsWith(".pabcproj")) { co.ProjectCompiled = true; } if (OutputDirectory != "") { co.OutputDirectory = OutputDirectory; } co.Rebuild = Rebuild; co.Debug = Debug; co.UseDllForSystemUnits = UseDll; AllFilesCount++; if (Compiler.Compile(co) != null) { SuccessFilesCount++; } if (IgnoreNotSupportedError) { if ((Compiler.ErrorsList.Count == 1) && (Compiler.ErrorsList[0] is Errors.SemanticNonSupportedError)) { Compiler.ErrorsList.Clear(); SuccessFilesCount++; } } if (Compiler.ErrorsList.Count > 0) { //Console.Beep(); if (short_output) { Console.WriteLine(); } Console.ForegroundColor = ConsoleColor.Gray; for (int i = 0; i < Compiler.ErrorsList.Count; i++) { WriteErrorText("[" + i + "]"); if (Compiler.ErrorsList[i] is LocatedError) { SourceLocation sl; if ((sl = (Compiler.ErrorsList[i] as LocatedError).SourceLocation) != null) { Console.WriteLine(string.Format("[{0},{1}] {2}: {3}", sl.BeginPosition.Line, sl.BeginPosition.Column, Path.GetFileName(sl.FileName), Compiler.ErrorsList[i].Message)); } else { Console.WriteLine(Compiler.ErrorsList[i]); } } else { if (Compiler.ErrorsList[i] is CompilerInternalError) { Console.ForegroundColor = ConsoleColor.Red; } Console.WriteLine(Compiler.ErrorsList[i]); } } GlobalErrorsList.AddRange(Compiler.ErrorsList); if (PauseIfError) { Console.ReadKey(); } } else { if (!short_output) { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(string.Format(StringResourcesGet("OK_{0}MS_{1}LINES"), (DateTime.Now - ldt).TotalMilliseconds, Compiler.LinesCompiled)); } } Console.ForegroundColor = ConsoleColor.Gray; return(Compiler.ErrorsList.Count); }
public static int Main(string[] args) { // SSM 18.03.19 Делаю параметры командной строки. Формат: pabcnetc.exe /Dir1=value1 /Dir2=value2 ... fname dir // dir - это пережиток старого - так можно было задавать каталог раньше. Пока - увы - пусть останется // Пока сделаю только директивы /Help /H /? и /Debug=0(1) // Имя директивы - это одно слово. Равенства может не быть - тогда value директивы равно null // Вычленяем первое равенство и делим директиву: до него - name, после него - value. Если name или value - пустые строки, то ошибка DateTime ldt = DateTime.Now; PascalABCCompiler.StringResourcesLanguage.LoadDefaultConfig(); Compiler = new PascalABCCompiler.Compiler(null, null); StringResourcesLanguage.CurrentLanguageName = StringResourcesLanguage.AccessibleLanguages[0]; //Console.WriteLine("OK {0}ms", (DateTime.Now - ldt).TotalMilliseconds); ldt = DateTime.Now; //ShowConnectedParsers(); var n = args.Length; if (n == 0) { //Console.WriteLine(StringResourcesGet("COMMANDLINEISABSENT")); OutputHelp(); return(2); } var n1 = args.TakeWhile(a => a[0] == '/').Count(); // количество директив if (n1 < n - 2) { Console.WriteLine("Error in argument {0}", args[n1 + 2]); Console.WriteLine("Command line cannot contain any arguments after filename '{0}' and outdirname '{1}'", args[n1], args[n1 + 1]); return(4); } if (n1 == n) // только директивы { string name, value; var b = CheckAndSplitDirective(args[0], out name, out value); if (!b) // Сообщение уже будет выдано { return(4); } switch (name) { case "help": case "h": case "?": OutputHelp(); return(0); default: Console.WriteLine("Filename is absent. Nothing to compile"); return(4); } } FileName = args[n1]; // следующий аргумент за директивами - имя файла if (!File.Exists(FileName)) { Console.WriteLine(StringResourcesGet("FILEISABSENT{0}"), "'" + FileName + "'"); return(3); } outputType = CompilerOptions.OutputType.ConsoleApplicaton; CompilerOptions co = new CompilerOptions(FileName, outputType); if (FileName.ToLower().EndsWith(".pabcproj")) { co.ProjectCompiled = true; } if (n1 == n - 1) { co.OutputDirectory = ""; } else { co.OutputDirectory = args[n - 1]; } co.Rebuild = false; co.Debug = false; co.UseDllForSystemUnits = false; for (var i = 0; i < n1; i++) { var b = CheckAndApplyDirective(args[i], co); if (!b) { return(4); } } bool success = true; if (Compiler.Compile(co) != null) { Console.WriteLine("OK"); } else { Console.WriteLine(StringResourcesGet("COMPILEERRORS")); success = false; } // Console.WriteLine("OK {0}ms", (DateTime.Now - ldt).TotalMilliseconds); ///// for (int i = 0; i < Compiler.ErrorsList.Count; i++) { if (Compiler.ErrorsList[i] is LocatedError) { SourceLocation sl; if ((sl = (Compiler.ErrorsList[i] as LocatedError).SourceLocation) != null) { Console.WriteLine(string.Format("[{0},{1}] {2}: {3}", sl.BeginPosition.Line, sl.BeginPosition.Column, Path.GetFileName(sl.FileName), Compiler.ErrorsList[i].Message)); } else { Console.WriteLine(Compiler.ErrorsList[i]); } } break; // выйти после первой же ошибки } if (success) { return(0); } else { return(1); } }