function Read<T>(Self: file of T): T;
+function Elements<T>(Self: file of T): sequence of T;
+ Âîçâðàùàåò ïîñëåäîâàòåëüíîñòü ýëåìåíòîâ îòêðûòîãî òèïèçèðîâàííîãî ôàéëà |
+function Read<T>(Self: file of T): T;
Ñ÷èòûâàåò è âîçâðàùàåò ñëåäóþùèé ýëåìåíò òèïèçèðîâàííîãî ôàéëà |
function Read2<T>(Self: file of T): (T,T);
Ñ÷èòûâàåò è âîçâðàùàåò äâà ñëåäóþùèõ ýëåìåíòà òèïèçèðîâàííîãî ôàéëà â âèäå êîðòåæà |
diff --git a/PABCNetHelp/LangGuide/PABCSystemUnit/stand_text_files_methods.html b/PABCNetHelp/LangGuide/PABCSystemUnit/stand_text_files_methods.html
index 901d73bdd..98c020b45 100644
--- a/PABCNetHelp/LangGuide/PABCSystemUnit/stand_text_files_methods.html
+++ b/PABCNetHelp/LangGuide/PABCSystemUnit/stand_text_files_methods.html
@@ -227,5 +227,11 @@
Ïåðåèìåíîâûâàåò ôàéë, äàâàÿ åìó èìÿ newname (ôàéë äîëæåí áûòü
çàêðûò)
+
+
+ function Lines: sequence of
+ string;
+ Âîçâðàùàåò ïîñëåäîâàòåëüíîñòü ñòðîê îòêðûòîãî òåêñòîâîãî ôàéëà |
+
diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh
index 102d8623a..858d3fd8d 100644
--- a/ReleaseGenerators/PascalABCNET_version.nsh
+++ b/ReleaseGenerators/PascalABCNET_version.nsh
@@ -1 +1 @@
-!define VERSION '3.4.2.1994'
+!define VERSION '3.4.2.2003'
diff --git a/SyntaxTree/tree/SyntaxTreeStreamReader.cs b/SyntaxTree/tree/SyntaxTreeStreamReader.cs
index 3a452b895..46cfe36cd 100644
--- a/SyntaxTree/tree/SyntaxTreeStreamReader.cs
+++ b/SyntaxTree/tree/SyntaxTreeStreamReader.cs
@@ -3569,7 +3569,7 @@ namespace PascalABCCompiler.SyntaxTree
public void read_unnamed_type_object(unnamed_type_object _unnamed_type_object)
{
- read_expression(_unnamed_type_object);
+ read_addressed_value(_unnamed_type_object);
_unnamed_type_object.ne_list = _read_node() as name_assign_expr_list;
_unnamed_type_object.is_class = br.ReadBoolean();
_unnamed_type_object.new_ex = _read_node() as new_expr;
diff --git a/SyntaxTree/tree/SyntaxTreeStreamWriter.cs b/SyntaxTree/tree/SyntaxTreeStreamWriter.cs
index 923d65c48..38743722d 100644
--- a/SyntaxTree/tree/SyntaxTreeStreamWriter.cs
+++ b/SyntaxTree/tree/SyntaxTreeStreamWriter.cs
@@ -5500,7 +5500,7 @@ namespace PascalABCCompiler.SyntaxTree
public void write_unnamed_type_object(unnamed_type_object _unnamed_type_object)
{
- write_expression(_unnamed_type_object);
+ write_addressed_value(_unnamed_type_object);
if (_unnamed_type_object.ne_list == null)
{
bw.Write((byte)0);
diff --git a/SyntaxTree/tree/Tree.cs b/SyntaxTree/tree/Tree.cs
index 771558852..f2e0a4cd5 100644
--- a/SyntaxTree/tree/Tree.cs
+++ b/SyntaxTree/tree/Tree.cs
@@ -42397,9 +42397,11 @@ namespace PascalABCCompiler.SyntaxTree
///Это - сахарная конструкция.
/// Объект безымянного класса. Например: new class(Name := 'Иванов'; Age := 25);
/// new_ex - это узел для генерации кода, основной узел предназначен для форматирования
+
+/// Сделал потомком addressed_value из-за #1843
///
[Serializable]
- public partial class unnamed_type_object : expression
+ public partial class unnamed_type_object : addressed_value
{
///
diff --git a/SyntaxTree/tree/tree.xml b/SyntaxTree/tree/tree.xml
index 464963d03..dbf843a02 100644
--- a/SyntaxTree/tree/tree.xml
+++ b/SyntaxTree/tree/tree.xml
@@ -2558,7 +2558,7 @@
-
+
@@ -4398,7 +4398,7 @@
-
+
diff --git a/TestSuite/CompilationSamples/GraphWPF.pas b/TestSuite/CompilationSamples/GraphWPF.pas
index 69c4e09f3..6fb4262a0 100644
--- a/TestSuite/CompilationSamples/GraphWPF.pas
+++ b/TestSuite/CompilationSamples/GraphWPF.pas
@@ -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);
diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas
index 29d1e1101..fd53256ce 100644
--- a/TestSuite/CompilationSamples/PABCSystem.pas
+++ b/TestSuite/CompilationSamples/PABCSystem.pas
@@ -409,6 +409,8 @@ type
procedure Append;
/// Открывает текстовый файл на дополнение в указанной кодировке
procedure Append(en: Encoding);
+ /// Возвращает последовательность строк открытого текстового файла
+ function Lines: sequence of string;
end;
/// Тип текстового файла
@@ -5607,6 +5609,14 @@ procedure Text.Append := PABCSystem.Append(Self);
procedure Text.Append(en: Encoding) := PABCSystem.Append(Self,en);
+function Text.Lines: sequence of string;
+begin
+ Self.sr.BaseStream.Position := 0;
+ while not Eof do
+ yield ReadlnString;
+end;
+
+
// -----------------------------------------------------
// AbstractBinaryFile methods
@@ -8653,8 +8663,6 @@ function MinBy(Self: sequence of T; selector: T->TKey): T; extensionmet
begin
if selector = nil then
raise new ArgumentNullException('selector');
- if not Self.Any() then
- raise new InvalidOperationException('Empty sequence');
var comp := Comparer&.Default;
Result := Self.Aggregate((min, x)-> comp.Compare(selector(x), selector(min)) < 0 ? x : min);
@@ -8665,8 +8673,6 @@ function MaxBy(Self: sequence of T; selector: T->TKey): T; extensionmet
begin
if selector = nil then
raise new ArgumentNullException('selector');
- if not Self.Any() then
- raise new InvalidOperationException('Empty sequence');
var comp := Comparer&.Default;
Result := Self.Aggregate((max, x)-> comp.Compare(selector(x), selector(max)) > 0 ? x : max);
@@ -8677,8 +8683,6 @@ function LastMinBy(Self: sequence of T; selector: T->TKey): T; extensio
begin
if selector = nil then
raise new ArgumentNullException('selector');
- if not Self.Any() then
- raise new InvalidOperationException('Empty sequence');
var comp := Comparer&.Default;
Result := Self.Aggregate((min, x)-> comp.Compare(selector(x), selector(min)) <= 0 ? x : min);
@@ -8689,8 +8693,6 @@ function LastMaxBy(Self: sequence of T; selector: T->TKey): T; extensio
begin
if selector = nil then
raise new ArgumentNullException('selector');
- if not Self.Any() then
- raise new InvalidOperationException('Empty sequence');
var comp := Comparer&.Default;
Result := Self.Aggregate((max, x)-> comp.Compare(selector(x), selector(max)) >= 0 ? x : max);
diff --git a/TestSuite/CompilationSamples/PT4.pas b/TestSuite/CompilationSamples/PT4.pas
index eaa71d33d..614ba8661 100644
--- a/TestSuite/CompilationSamples/PT4.pas
+++ b/TestSuite/CompilationSamples/PT4.pas
@@ -410,7 +410,7 @@ procedure Put(param: boolean);
procedure Put(param: PNode);
procedure Put(param: Node);
-{
+
//Ввод этих данных не поддерживается
///- read(a,b,...)
/// Вводит значения a,b,... из окна электронного задачника
@@ -447,7 +447,6 @@ procedure Read(var val: Node);
procedure Read(var val: PNode);
///--
procedure Readln;
-}
procedure Print(params args: array of object);
procedure Println(params args: array of object);
diff --git a/TestSuite/CompilationSamples/graph3d.pas b/TestSuite/CompilationSamples/graph3d.pas
index f2dd1954c..a01e595bf 100644
--- a/TestSuite/CompilationSamples/graph3d.pas
+++ b/TestSuite/CompilationSamples/graph3d.pas
@@ -757,7 +757,8 @@ type
Group3D = class(ObjectWithChildren3D)
protected
function CreateObject: Object3D; override := new Group3D(X, Y, Z);
- public
+ //public
+ protected
constructor(x, y, z: real) := CreateBase0(new ModelVisual3D, x, y, z);
constructor(x, y, z: real; lst: sequence of Object3D);
diff --git a/TestSuite/Set_char_string.pas b/TestSuite/Set_char_string.pas
new file mode 100644
index 000000000..1c3c4ac7f
--- /dev/null
+++ b/TestSuite/Set_char_string.pas
@@ -0,0 +1,5 @@
+begin
+ var s: set of string := ['b','d '];
+ foreach var o in s do
+ Assert(o.GetType = typeof(string));
+end.
\ No newline at end of file
diff --git a/TestSuite/formatter_tests/input/PT4.pas b/TestSuite/formatter_tests/input/PT4.pas
index eaa71d33d..614ba8661 100644
--- a/TestSuite/formatter_tests/input/PT4.pas
+++ b/TestSuite/formatter_tests/input/PT4.pas
@@ -410,7 +410,7 @@ procedure Put(param: boolean);
procedure Put(param: PNode);
procedure Put(param: Node);
-{
+
//Ввод этих данных не поддерживается
///- read(a,b,...)
/// Вводит значения a,b,... из окна электронного задачника
@@ -447,7 +447,6 @@ procedure Read(var val: Node);
procedure Read(var val: PNode);
///--
procedure Readln;
-}
procedure Print(params args: array of object);
procedure Println(params args: array of object);
diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs
index 05c176a6f..b2c53e295 100644
--- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs
+++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs
@@ -4842,8 +4842,6 @@ namespace PascalABCCompiler.TreeConverter
types.AddElement(en.type);
}
}
- expressions_list consts_copy = new expressions_list();
- consts_copy.AddRange(consts);
type_node ctn = null;
if (consts.Count > 0)
{
@@ -4855,7 +4853,22 @@ namespace PascalABCCompiler.TreeConverter
}
else ctn = SystemLibrary.SystemLibInitializer.TypedSetType.sym_info as type_node;
+
+ /*if (el_type == SystemLibrary.SystemLibrary.string_type)
+ {
+ for (int i = 0; i < consts.Count; i++)
+ if (consts[i].type == SystemLibrary.SystemLibrary.char_type)
+ {
+ consts[i] = convertion_data_and_alghoritms.convert_type(consts[i], el_type);
+ }
+ } */ // Не работает ! SSM 19.03.19
+
+ expressions_list consts_copy = new expressions_list();
+ consts_copy.AddRange(consts);
+
function_node fn = convertion_data_and_alghoritms.select_function(consts, SystemLibrary.SystemLibInitializer.CreateSetProcedure.SymbolInfo, (SystemLibrary.SystemLibInitializer.CreateSetProcedure.sym_info is common_namespace_function_node)?(SystemLibrary.SystemLibInitializer.CreateSetProcedure.sym_info as common_namespace_function_node).loc:null);
+
+
if (fn is common_namespace_function_node)
{
common_namespace_function_call cnfc = new common_namespace_function_call(fn as common_namespace_function_node, get_location(_pascal_set_constant));
@@ -17458,7 +17471,7 @@ namespace PascalABCCompiler.TreeConverter
if (tn == null || tn is null_type_node || tn.ImplementingInterfaces == null)
return false;
- if (tn.element_type != null) // еще может быть множество set of T - 22.02.16 SSM
+ if (tn.element_type != null && tn.type_special_kind != SemanticTree.type_special_kind.typed_file) // еще может быть множество set of T - 22.02.16 SSM
{
elem_type = tn.element_type;
return true;
diff --git a/VisualPascalABCNET/VisualPascalABCNET.csproj b/VisualPascalABCNET/VisualPascalABCNET.csproj
index 7e0b78b1b..2f4406c07 100644
--- a/VisualPascalABCNET/VisualPascalABCNET.csproj
+++ b/VisualPascalABCNET/VisualPascalABCNET.csproj
@@ -10,7 +10,7 @@
Properties
VisualPascalABC
PascalABCNET
- ABCNET32.ico
+ _ABC13.ico
LocalIntranet
false
False
@@ -668,6 +668,7 @@
+
diff --git a/VisualPascalABCNET/VisualPascalABCNET_40.csproj b/VisualPascalABCNET/VisualPascalABCNET_40.csproj
index f2a9ebc51..2ddd04ec2 100644
--- a/VisualPascalABCNET/VisualPascalABCNET_40.csproj
+++ b/VisualPascalABCNET/VisualPascalABCNET_40.csproj
@@ -10,7 +10,7 @@
Properties
VisualPascalABC
PascalABCNET
- ABCNET32.ico
+ _ABC13.ico
LocalIntranet
false
False
@@ -73,6 +73,7 @@
AnyCPU
4096
+
app.manifest
diff --git a/VisualPascalABCNET/_ABC13.ico b/VisualPascalABCNET/_ABC13.ico
new file mode 100644
index 000000000..d78e42962
Binary files /dev/null and b/VisualPascalABCNET/_ABC13.ico differ
diff --git a/_NewAppIcons/ABC_NET3.svg b/_NewAppIcons/ABC_NET3.svg
new file mode 100644
index 000000000..5dd131ec3
--- /dev/null
+++ b/_NewAppIcons/ABC_NET3.svg
@@ -0,0 +1,150 @@
+
+
+
+
diff --git a/_NewAppIcons/_ABC10.ico b/_NewAppIcons/_ABC10.ico
new file mode 100644
index 000000000..1056ab075
Binary files /dev/null and b/_NewAppIcons/_ABC10.ico differ
diff --git a/_NewAppIcons/_ABC13.ico b/_NewAppIcons/_ABC13.ico
new file mode 100644
index 000000000..2cbcfd8fa
Binary files /dev/null and b/_NewAppIcons/_ABC13.ico differ
diff --git a/_NewAppIcons/_copy.ico b/_NewAppIcons/_copy.ico
new file mode 100644
index 000000000..7364b40fe
Binary files /dev/null and b/_NewAppIcons/_copy.ico differ
diff --git a/_NewAppIcons/_cut.ico b/_NewAppIcons/_cut.ico
new file mode 100644
index 000000000..65dd2d1e4
Binary files /dev/null and b/_NewAppIcons/_cut.ico differ
diff --git a/_NewAppIcons/_format.ico b/_NewAppIcons/_format.ico
new file mode 100644
index 000000000..49faf8037
Binary files /dev/null and b/_NewAppIcons/_format.ico differ
diff --git a/_NewAppIcons/_help.ico b/_NewAppIcons/_help.ico
new file mode 100644
index 000000000..a49ad6c76
Binary files /dev/null and b/_NewAppIcons/_help.ico differ
diff --git a/_NewAppIcons/_new.ico b/_NewAppIcons/_new.ico
new file mode 100644
index 000000000..b3b9cf1e5
Binary files /dev/null and b/_NewAppIcons/_new.ico differ
diff --git a/_NewAppIcons/_open.ico b/_NewAppIcons/_open.ico
new file mode 100644
index 000000000..5d07ad598
Binary files /dev/null and b/_NewAppIcons/_open.ico differ
diff --git a/_NewAppIcons/_options.ico b/_NewAppIcons/_options.ico
new file mode 100644
index 000000000..910df3e01
Binary files /dev/null and b/_NewAppIcons/_options.ico differ
diff --git a/_NewAppIcons/_paste.ico b/_NewAppIcons/_paste.ico
new file mode 100644
index 000000000..52e52485f
Binary files /dev/null and b/_NewAppIcons/_paste.ico differ
diff --git a/_NewAppIcons/_redo.ico b/_NewAppIcons/_redo.ico
new file mode 100644
index 000000000..1091f05b6
Binary files /dev/null and b/_NewAppIcons/_redo.ico differ
diff --git a/_NewAppIcons/_run.ico b/_NewAppIcons/_run.ico
new file mode 100644
index 000000000..01626209e
Binary files /dev/null and b/_NewAppIcons/_run.ico differ
diff --git a/_NewAppIcons/_save.ico b/_NewAppIcons/_save.ico
new file mode 100644
index 000000000..00996e95d
Binary files /dev/null and b/_NewAppIcons/_save.ico differ
diff --git a/_NewAppIcons/_undo.ico b/_NewAppIcons/_undo.ico
new file mode 100644
index 000000000..5d69ca0c4
Binary files /dev/null and b/_NewAppIcons/_undo.ico differ
diff --git a/bin/Lib/Controls.pas b/bin/Lib/Controls.pas
index 7e26b9a43..b7ca2c0ea 100644
--- a/bin/Lib/Controls.pas
+++ b/bin/Lib/Controls.pas
@@ -77,23 +77,31 @@ type
TextLabelT = class(CommonControl)
protected
function b: GTextBlock := element as GTextBlock;
- function GetText: string := InvokeString(()->b.Text);
- procedure SetTextP(t: string) := b.Text := t;
- procedure SetText(t: string) := Invoke(SetTextP,t);
procedure CreateP(Txt: string);
begin
- element := new GTextBlock;
+ var tb := new GTextBlock;
+ element := tb;
//element.Margin := new Thickness(0,0,0,8);
//element.Margin := new Thickness(5,5,5,0);
Text := Txt;
ActivePanel.Children.Add(b);
end;
- public
- constructor Create(Txt: string);
+ procedure CreatePXY(x,y: real; Txt: string);
begin
- Invoke(CreateP,Txt);
+ var tb := new GTextBlock;
+ element := tb;
+ tb.Background := new SolidColorBrush(Colors.White);
+ tb.FontSize := 20;
+ tb.Opacity := 0.7;
+ Canvas.SetLeft(element,x);
+ Canvas.SetTop(element,y);
+ Text := Txt;
+ ActivePanel.Children.Add(b);
end;
- property Text: string read GetText write SetText;
+ public
+ constructor Create(Txt: string) := Invoke(CreateP,Txt);
+ constructor Create(x,y: real; Txt: string) := Invoke(CreatePXY,x,y,Txt);
+ property Text: string read InvokeString(()->b.Text) write Invoke(procedure(t: string) -> b.Text := t,value);
end;
///!#
@@ -241,16 +249,18 @@ type
end;
- function Button(Txt: string): ButtonT;
- function TextLabel(Txt: string): TextLabelT;
- function TextBox(Txt: string := ''; w: real := 0): TextBoxT;
- function IntegerBox(w: real := 0): IntegerBoxT;
- function Slider(min: real := 0; max: real := 10; val: real := 0): SliderT;
-
- procedure EmptyBlock(sz: integer := 16);
+function Button(Txt: string): ButtonT;
+function TextLabel(Txt: string): TextLabelT;
+function TextLabel(x,y: real; Txt: string): TextLabelT;
+function TextBox(Txt: string := ''; w: real := 0): TextBoxT;
+function IntegerBox(w: real := 0): IntegerBoxT;
+function Slider(min: real := 0; max: real := 10; val: real := 0): SliderT;
+
+procedure EmptyBlock(sz: integer := 16);
implementation
+uses GraphWPF;
uses System.Windows;
uses System.Windows.Controls;
uses System.Windows.Controls.Primitives;
@@ -314,6 +324,7 @@ procedure AddStatusBar(Height: real) := Invoke(AddStatusBarP,Height);
function Button(Txt: string): ButtonT := ButtonT.Create(Txt);
function TextLabel(Txt: string): TextLabelT := TextLabelT.Create(Txt);
+function TextLabel(x,y: real; Txt: string): TextLabelT := TextLabelT.Create(x,y,Txt);
function TextBox(Txt: string; w: real): TextBoxT := TextBoxT.Create(Txt,w);
function IntegerBox(w: real): IntegerBoxT := IntegerBoxT.Create(w);
function Slider(min,max,val: real): SliderT := SliderT.Create(min,max,val);
@@ -325,6 +336,11 @@ begin
e.Width:= sz;
end;
+procedure SetActivePanelInit;
+begin
+ ActivePanel := MainWindow.MainPanel.Children[0] as Panel
+end;
begin
+ Invoke(SetActivePanelInit);
end.
\ No newline at end of file
diff --git a/bin/Lib/GraphWPF.pas b/bin/Lib/GraphWPF.pas
index 69c4e09f3..6fb4262a0 100644
--- a/bin/Lib/GraphWPF.pas
+++ b/bin/Lib/GraphWPF.pas
@@ -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);
diff --git a/bin/Lib/PABCExtensions.pas b/bin/Lib/PABCExtensions.pas
index 395052359..b8d8f89e2 100644
--- a/bin/Lib/PABCExtensions.pas
+++ b/bin/Lib/PABCExtensions.pas
@@ -142,6 +142,14 @@ begin
end;
end;
+/// Возвращает последовательность элементов открытого типизированного файла
+function Elements(Self: file of T): sequence of T; extensionmethod;
+begin
+ Reset(Self); // Если файл открыт, то файловый указатель просто устанавливается на 0 позицию
+ Result := Self.ReadElements;
+end;
+
+
/// Открывает типизированный файл, возвращает последовательность его элементов и закрывает его
function ReadElements(fname: string): sequence of T;
begin
diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas
index 29d1e1101..4272c192e 100644
--- a/bin/Lib/PABCSystem.pas
+++ b/bin/Lib/PABCSystem.pas
@@ -409,6 +409,8 @@ type
procedure Append;
/// Открывает текстовый файл на дополнение в указанной кодировке
procedure Append(en: Encoding);
+ /// Возвращает последовательность строк открытого текстового файла
+ function Lines: sequence of string;
end;
/// Тип текстового файла
@@ -3029,7 +3031,7 @@ begin
Result.high := high;
end;
-[System.Diagnostics.DebuggerStepThrough]
+//[System.Diagnostics.DebuggerStepThrough]
function CreateObjDiapason(low, high: object): Diapason;
begin
Result.clow := low;
@@ -3039,9 +3041,39 @@ end;
[System.Diagnostics.DebuggerStepThrough]
function CreateSet(params elems: array of object): TypedSet;
begin
+ var chars := false;
+ var strings := false;
+ var others := false;
+ foreach var x in elems do
+ begin
+ if (x is char) or (x is Diapason) and (Diapason(x).clow is char) then
+ chars := true
+ else if x is string then
+ strings := true
+ else
+ begin
+ others := true;
+ break
+ end;
+ end;
+
Result := new TypedSet();
- for var i := 0 to elems.Length - 1 do
- Result.IncludeElement(elems[i]);
+
+ if chars and strings and not others then
+ foreach var x in elems do
+ if x is char then
+ Result.IncludeElement(x.ToString)
+ else if (x is Diapason) and (Diapason(x).clow is char) then
+ begin
+ var c1 := char(Diapason(x).clow);
+ var c2 := char(Diapason(x).chigh);
+ for var cc := c1 to c2 do
+ Result.IncludeElement(cc.ToString)
+ end
+ else Result.IncludeElement(x)
+ else
+ foreach var x in elems do
+ Result.IncludeElement(x);
end;
[System.Diagnostics.DebuggerStepThrough]
@@ -5607,6 +5639,14 @@ procedure Text.Append := PABCSystem.Append(Self);
procedure Text.Append(en: Encoding) := PABCSystem.Append(Self,en);
+function Text.Lines: sequence of string;
+begin
+ Self.sr.BaseStream.Position := 0;
+ while not Eof do
+ yield ReadlnString;
+end;
+
+
// -----------------------------------------------------
// AbstractBinaryFile methods
@@ -8653,8 +8693,6 @@ function MinBy(Self: sequence of T; selector: T->TKey): T; extensionmet
begin
if selector = nil then
raise new ArgumentNullException('selector');
- if not Self.Any() then
- raise new InvalidOperationException('Empty sequence');
var comp := Comparer&.Default;
Result := Self.Aggregate((min, x)-> comp.Compare(selector(x), selector(min)) < 0 ? x : min);
@@ -8665,8 +8703,6 @@ function MaxBy(Self: sequence of T; selector: T->TKey): T; extensionmet
begin
if selector = nil then
raise new ArgumentNullException('selector');
- if not Self.Any() then
- raise new InvalidOperationException('Empty sequence');
var comp := Comparer&.Default;
Result := Self.Aggregate((max, x)-> comp.Compare(selector(x), selector(max)) > 0 ? x : max);
@@ -8677,8 +8713,6 @@ function LastMinBy(Self: sequence of T; selector: T->TKey): T; extensio
begin
if selector = nil then
raise new ArgumentNullException('selector');
- if not Self.Any() then
- raise new InvalidOperationException('Empty sequence');
var comp := Comparer&.Default;
Result := Self.Aggregate((min, x)-> comp.Compare(selector(x), selector(min)) <= 0 ? x : min);
@@ -8689,8 +8723,6 @@ function LastMaxBy(Self: sequence of T; selector: T->TKey): T; extensio
begin
if selector = nil then
raise new ArgumentNullException('selector');
- if not Self.Any() then
- raise new InvalidOperationException('Empty sequence');
var comp := Comparer&.Default;
Result := Self.Aggregate((max, x)-> comp.Compare(selector(x), selector(max)) >= 0 ? x : max);
diff --git a/bin/Lib/PT4.pas b/bin/Lib/PT4.pas
index eaa71d33d..614ba8661 100644
--- a/bin/Lib/PT4.pas
+++ b/bin/Lib/PT4.pas
@@ -410,7 +410,7 @@ procedure Put(param: boolean);
procedure Put(param: PNode);
procedure Put(param: Node);
-{
+
//Ввод этих данных не поддерживается
///- read(a,b,...)
/// Вводит значения a,b,... из окна электронного задачника
@@ -447,7 +447,6 @@ procedure Read(var val: Node);
procedure Read(var val: PNode);
///--
procedure Readln;
-}
procedure Print(params args: array of object);
procedure Println(params args: array of object);
diff --git a/bin/Lng/Eng/PABCNETC.dat b/bin/Lng/Eng/PABCNETC.dat
index 2455591d4..3953b33e4 100644
--- a/bin/Lng/Eng/PABCNETC.dat
+++ b/bin/Lng/Eng/PABCNETC.dat
@@ -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
diff --git a/bin/Lng/Rus/PABCNETC.dat b/bin/Lng/Rus/PABCNETC.dat
index 1e8b08eaa..450529a24 100644
--- a/bin/Lng/Rus/PABCNETC.dat
+++ b/bin/Lng/Rus/PABCNETC.dat
@@ -14,7 +14,7 @@ CONNECTED_PARSERS=Подключены парсеры:
CONNECTED_CONVERSIONS=Подключены преобразования:
STARTING=Запуск...
COMMANDLINEISABSENT=Отсутствует командная строка
-FILEISABSENT{0}=Отсутствует файл {0}
+FILEISABSENT{0}=Файл {0} не найден
COMPILEERRORS=Ошибки компиляции:
HELP=17LINES
diff --git a/bin/Lng/Rus/PascalABCParser.dat b/bin/Lng/Rus/PascalABCParser.dat
index 2a583ad9b..2afe0dfb6 100644
--- a/bin/Lng/Rus/PascalABCParser.dat
+++ b/bin/Lng/Rus/PascalABCParser.dat
@@ -66,7 +66,7 @@ TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7=Количество элементов
TWO_NILS_IN_QUESTION_EXPR=Условное выражение не может содержать константы nil по обеим веткам
DOT_QUECTION_IN_SHORT_FUN=Выражение с ?. не может фигурировать в коротком определении функции без возвращаемого значения
BAD_INT2=Слишком маленькое целое
-INVALID_INTERFACE_MEMBER=Члены интерфейса не могут иметь определение
+INVALID_INTERFACE_MEMBER=Интерфейсы не могут содержать поля и реализацию методов
EXTENDED_INDEXED_PROPERTIES=Индексные свойства не могут быть расширенными
TWO_STRING_LITERALS_IN_SUCCESSION=Две литеральные строковые константы не могут стоять подряд
ATTRIBUTE_REDECLARED=Повторное применение атрибута
diff --git a/bin/Lng/Rus/SemanticErrors_ssyy.dat b/bin/Lng/Rus/SemanticErrors_ssyy.dat
index c0a4efe81..53a2dc04b 100644
--- a/bin/Lng/Rus/SemanticErrors_ssyy.dat
+++ b/bin/Lng/Rus/SemanticErrors_ssyy.dat
@@ -4,7 +4,7 @@ TEMPLATE_ARGUMENTS_COUNT_MISMATCH=Неправильное число парам
TEMPLATE_PARAMETER_{0}_REDEFINITION=Повторное описание параметра {0}
INHERITED_CONSTRUCTOR_CALL_MUST_BE_FIRST=Вызов конструктора предка должен быть первым в теле конструктора
INHERITED_CONSTRUCTOR_CALL_EXPECTED=Необходимо вызвать конструктор предка
-INVALID_INTERFACE_MEMBER=Члены интерфейса не могут иметь поля, константы и реализацию методов
+INVALID_INTERFACE_MEMBER=Интерфейсы не могут содержать поля и реализацию методов
{0}_IS_NOT_INTERFACE={0} не является интерфейсом
INTERFACE_FUNCTION_WITH_BODY=Нельзя определять тело функции или процедуры интерфейса
CONSTRUCTOR_IN_INTERFACE=Интерфейс не может содержать конструкторы
diff --git a/bin/Lng/Rus/SyntaxTreeVisitorsErrors.dat b/bin/Lng/Rus/SyntaxTreeVisitorsErrors.dat
index 29bc6eb75..3af3c3016 100644
--- a/bin/Lng/Rus/SyntaxTreeVisitorsErrors.dat
+++ b/bin/Lng/Rus/SyntaxTreeVisitorsErrors.dat
@@ -24,5 +24,5 @@ Var_{0}_is_already_defined=Переменная {0} уже определена
?._CANNOT_BE_IN_THIS_CONTEXT=Операция ?. не может располагаться в этом контексте
-INVALID_INTERFACE_MEMBER=Члены интерфейса не могут иметь определение
+INVALID_INTERFACE_MEMBER=Интерфейсы не могут содержать поля и реализацию методов
INDEXED_AUTO_PROPERTY=Автосвойства не могут быть индексными
\ No newline at end of file
diff --git a/bin/PascalABCNET.chm b/bin/PascalABCNET.chm
index 4dad76338..e052a247a 100644
Binary files a/bin/PascalABCNET.chm and b/bin/PascalABCNET.chm differ
diff --git a/pabcnetc_clear/ConsoleCompiler.cs b/pabcnetc_clear/ConsoleCompiler.cs
index 323f2dcf8..c6c2d730b 100644
--- a/pabcnetc_clear/ConsoleCompiler.cs
+++ b/pabcnetc_clear/ConsoleCompiler.cs
@@ -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
Project
- a.pas
+ d:\a.pas
|