pabcnetcclear - добавление директив в командную строку и переработка диагностики ошибок
This commit is contained in:
parent
6550cecc2e
commit
90c406e0cc
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "4";
|
||||
public const string Build = "2";
|
||||
public const string Revision = "2001";
|
||||
public const string Revision = "2002";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%COREVERSION%=2
|
||||
%REVISION%=2001
|
||||
%MINOR%=4
|
||||
%REVISION%=2002
|
||||
%COREVERSION%=2
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.4.2.2001'
|
||||
!define VERSION '3.4.2.2002'
|
||||
|
|
|
|||
|
|
@ -478,6 +478,11 @@ procedure AddBottomPanel(Height: real := 100; c: Color := Colors.LightGray);
|
|||
|
||||
procedure AddStatusBar(Height: real := 24);}
|
||||
|
||||
{function GetDC: DrawingContext;
|
||||
procedure ReleaseDC(dc: DrawingContext);
|
||||
procedure FastDraw(d: DrawingContext->());
|
||||
procedure FastClear(var dc: DrawingContext);}
|
||||
|
||||
procedure __InitModule__;
|
||||
procedure __FinalizeModule__;
|
||||
|
||||
|
|
@ -551,6 +556,23 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure FastDraw(d: DrawingContext->());
|
||||
begin
|
||||
Invoke(()->
|
||||
begin
|
||||
var dc := GetDC;
|
||||
d(dc);
|
||||
ReleaseDC(dc);
|
||||
end);
|
||||
end;
|
||||
|
||||
procedure FastClear(var dc: DrawingContext);
|
||||
begin
|
||||
ReleaseDC(dc);
|
||||
Window.Clear;
|
||||
dc := GetDC;
|
||||
end;
|
||||
|
||||
function GetDC(t: Transform): DrawingContext;
|
||||
begin
|
||||
var visual := new DrawingVisual();
|
||||
|
|
@ -1313,7 +1335,6 @@ begin
|
|||
FillRectangle(0,0,Window.Width,Window.Height,c)
|
||||
end;
|
||||
|
||||
|
||||
procedure WindowTypeWPF.Clear := Invoke(WindowTypeClearP);
|
||||
|
||||
procedure WindowTypeWPF.Clear(c: Color) := Invoke(WindowTypeClearPC,c);
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ ERROR_PARSERS_NOT_FOUND=Error: Parsers not found!
|
|||
CONNECTED_PARSERS=Connected parsers:
|
||||
CONNECTED_CONVERSIONS=Connected conversions:
|
||||
STARTING=Starting...
|
||||
COMMANDLINEISABSENT=Command line is absent
|
||||
FILEISABSENT{0}=File {0} is absent
|
||||
COMMANDLINEISABSENT=Command line is empty
|
||||
FILEISABSENT{0}=File {0} not found
|
||||
COMPILEERRORS=Compile errors:
|
||||
|
||||
HELP=16LINES
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ CONNECTED_PARSERS=Подключены парсеры:
|
|||
CONNECTED_CONVERSIONS=Подключены преобразования:
|
||||
STARTING=Запуск...
|
||||
COMMANDLINEISABSENT=Отсутствует командная строка
|
||||
FILEISABSENT{0}=Отсутствует файл {0}
|
||||
FILEISABSENT{0}=Файл {0} не найден
|
||||
COMPILEERRORS=Ошибки компиляции:
|
||||
|
||||
HELP=17LINES
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
using System;
|
||||
using PascalABCCompiler.Errors;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PascalABCCompiler
|
||||
|
|
@ -38,8 +39,77 @@ namespace PascalABCCompiler
|
|||
}
|
||||
}
|
||||
|
||||
public static bool CheckAndSplitDirective(string directive, out string name, out string value)
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(directive[0] == '/');
|
||||
directive = directive.Remove(0, 1);
|
||||
|
||||
name = null;
|
||||
value = null;
|
||||
var ss = directive.Split(':');
|
||||
if (ss.Length>2)
|
||||
{
|
||||
Console.WriteLine("Directive can contain only one ':' sign");
|
||||
return false;
|
||||
}
|
||||
name = ss[0].ToLower();
|
||||
if (ss.Length > 1)
|
||||
value = ss[1].ToLower();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool ApplyDirective(string name, string value, CompilerOptions co)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "debug":
|
||||
switch (value)
|
||||
{
|
||||
case "0":
|
||||
co.Debug = false;
|
||||
co.Optimise = true;
|
||||
return true;
|
||||
case "1":
|
||||
co.Debug = true;
|
||||
return true;
|
||||
default:
|
||||
Console.WriteLine("Bad value in 'Debug' directive '{0}'. Acceptable values are 0 or 1", value);
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
Console.WriteLine("No such directive name: '{0}'", name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckAndApplyDirective(string directive, CompilerOptions co)
|
||||
{
|
||||
string name, value;
|
||||
var b = CheckAndSplitDirective(directive,out name, out value);
|
||||
if (!b)
|
||||
return false;
|
||||
|
||||
b = ApplyDirective(name, value, co);
|
||||
return b;
|
||||
}
|
||||
|
||||
public static void OutputHelp()
|
||||
{
|
||||
Console.WriteLine("Command line: ");
|
||||
Console.WriteLine("pabcnetcclear /directive1:value1 /directive2:value2 ... [inputfile]\n");
|
||||
Console.WriteLine("Available directives:\n /Help /H /?\n /Debug:0(1)\n");
|
||||
Console.WriteLine("/Debug:0 generates code with all .NET optimizations!");
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
|
|
@ -47,33 +117,72 @@ namespace PascalABCCompiler
|
|||
StringResourcesLanguage.CurrentLanguageName = StringResourcesLanguage.AccessibleLanguages[0];
|
||||
//Console.WriteLine("OK {0}ms", (DateTime.Now - ldt).TotalMilliseconds);
|
||||
ldt = DateTime.Now;
|
||||
|
||||
|
||||
//ShowConnectedParsers();
|
||||
|
||||
if (args.Length == 0)
|
||||
var n = args.Length;
|
||||
if (n == 0)
|
||||
{
|
||||
Console.WriteLine(StringResourcesGet("COMMANDLINEISABSENT"));
|
||||
//Console.WriteLine(StringResourcesGet("COMMANDLINEISABSENT"));
|
||||
OutputHelp();
|
||||
return 2;
|
||||
}
|
||||
|
||||
FileName = args[0];
|
||||
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);
|
||||
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)
|
||||
if (n1 == n - 1)
|
||||
co.OutputDirectory = "";
|
||||
else co.OutputDirectory = args[1];
|
||||
else co.OutputDirectory = args[n - 1];
|
||||
co.Rebuild = false;
|
||||
co.Debug = true;
|
||||
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");
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
<RemoteDebugMachine>
|
||||
</RemoteDebugMachine>
|
||||
<StartAction>Project</StartAction>
|
||||
<StartArguments>a.pas</StartArguments>
|
||||
<StartArguments>d:\a.pas</StartArguments>
|
||||
<StartPage>
|
||||
</StartPage>
|
||||
<StartProgram>
|
||||
|
|
|
|||
Loading…
Reference in a new issue