From 84205f86bf5a5ba76585e5524e5884862e259b14 Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Fri, 19 Jul 2024 11:30:18 +0300 Subject: [PATCH] =?UTF-8?q?SetOf=20=D0=BD=D0=B0=20=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=83=20[1,2,3]=20=D0=9F=D1=80=D0=B5=D0=BE=D0=B1=D1=80?= =?UTF-8?q?=D0=B0=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B0?= =?UTF-8?q?=D1=81=D1=81=D0=B8=D0=B2=D0=BE=D0=B2=20=D1=81=D1=82=D0=B0=D0=BD?= =?UTF-8?q?=D0=B4=D0=B0=D1=80=D1=82=D0=BD=D1=8B=D1=85=20=D1=82=D0=B8=D0=BF?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=BA=20=D0=BC=D0=BD=D0=BE=D0=B6=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D0=B2=D0=B0=D0=BC=20=D1=82=D0=BE=D0=B3=D0=BE=20=D0=B6?= =?UTF-8?q?=D0=B5=20=D1=82=D0=B8=D0=BF=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PascalABCParserNewSaushkin/ABCPascal.cs | 2 +- .../PascalABCParserNewSaushkin/ABCPascal.y | 2 +- .../ABCPascalYacc.cs | 10 +++++-- Parsers/PascalABCParserNewSaushkin/PABC.ymc | 1 + bin/Lib/PABCExtensions.pas | 30 +++++++++++++++++++ bin/Lib/PABCSystem.pas | 15 +--------- 6 files changed, 42 insertions(+), 18 deletions(-) diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index 918ffd533..a6b574a5d 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs @@ -2,7 +2,7 @@ // This CSharp output file generated by Gardens Point LEX // Version: 1.1.3.301 // Machine: DESKTOP-G8V08V4 -// DateTime: 15.07.2024 13:28:05 +// DateTime: 19.07.2024 11:28:35 // UserName: ????????? // GPLEX input file // GPLEX frame file diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y index eebd4936f..73eaf8ea0 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y @@ -986,7 +986,7 @@ const_factor const_set : tkSquareOpen elem_list tkSquareClose - { + { $$ = new pascal_set_constant($2 as expression_list, @$); } | tkVertParen elem_list tkVertParen diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index b8b06825d..c6227f0ce 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs @@ -2,7 +2,7 @@ // GPPG version 1.3.6 // Machine: DESKTOP-G8V08V4 -// DateTime: 15.07.2024 13:28:05 +// DateTime: 19.07.2024 11:28:36 // UserName: ????????? // Input file @@ -3661,7 +3661,13 @@ public partial class GPPGParser: ShiftReduceParser tkSquareOpen, elem_list, tkSquareClose -{ +{ + // �?сли elem_list п�?с�? или соде�?жи�? диапазон, �?о э�?о множес�?во, ина�?е массив. С PascalABC.NET 3.10 + var is_set = false; + var el = ValueStack[ValueStack.Depth-2].stn as expression_list; + if (el.Count == 0) + is_set = true; + CurrentSemanticValue.ex = new pascal_set_constant(ValueStack[ValueStack.Depth-2].stn as expression_list, CurrentLocationSpan); } break; diff --git a/Parsers/PascalABCParserNewSaushkin/PABC.ymc b/Parsers/PascalABCParserNewSaushkin/PABC.ymc index 1313c78af..6a411cf33 100644 --- a/Parsers/PascalABCParserNewSaushkin/PABC.ymc +++ b/Parsers/PascalABCParserNewSaushkin/PABC.ymc @@ -384,5 +384,6 @@ script= + diff --git a/bin/Lib/PABCExtensions.pas b/bin/Lib/PABCExtensions.pas index ac66024ed..1d9e9d7e7 100644 --- a/bin/Lib/PABCExtensions.pas +++ b/bin/Lib/PABCExtensions.pas @@ -409,6 +409,36 @@ begin Result += x; end;} +/// Функция создания множества set по указанным значениям +function SetOf(params a: array of T): set of T; +begin + Result := TypedSet.InitBy(a); +end; + +///-- +function operator implicit(a: array of integer): set of integer; extensionmethod := TypedSet.InitBy(a); +///-- +function operator implicit(a: array of real): set of real; extensionmethod := TypedSet.InitBy(a); +///-- +function operator implicit(a: array of string): set of string; extensionmethod := TypedSet.InitBy(a); +///-- +function operator implicit(a: array of char): set of char; extensionmethod := TypedSet.InitBy(a); +///-- +function operator implicit(a: array of shortint): set of shortint; extensionmethod := TypedSet.InitBy(a); +///-- +function operator implicit(a: array of int64): set of int64; extensionmethod := TypedSet.InitBy(a); +///-- +function operator implicit(a: array of byte): set of byte; extensionmethod := TypedSet.InitBy(a); +///-- +function operator implicit(a: array of word): set of word; extensionmethod := TypedSet.InitBy(a); +///-- +function operator implicit(a: array of longword): set of longword; extensionmethod := TypedSet.InitBy(a); +///-- +function operator implicit(a: array of BigInteger): set of BigInteger; extensionmethod := TypedSet.InitBy(a); +///-- +function operator implicit(a: array of decimal): set of decimal; extensionmethod := TypedSet.InitBy(a); +///-- +function operator implicit(a: array of single): set of single; extensionmethod := TypedSet.InitBy(a); //------------------------------------------------------------------------------ // Операции для procedure diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index ae182ca92..ced27eaae 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -519,9 +519,7 @@ type function ToString: string; override; class function operator implicit(s: TypedSet): HashSet; class function operator implicit(s: HashSet): TypedSet; - class function operator implicit(s: array of T): TypedSet; class function InitBy(s: sequence of T): TypedSet; - //class function operator implicit(a: array of T): TypedSet; function Count: integer := ht.Count; procedure Print(delim: string := ' '); procedure Println(delim: string := ' '); @@ -3537,7 +3535,7 @@ begin end; ///-- -class function TypedSet.operator implicit(s: array of T): TypedSet; +{class function TypedSet.operator implicit(s: array of T): TypedSet; begin var ts := new TypedSet(); foreach key: T in s do @@ -3545,17 +3543,6 @@ begin ts.ht[key] := key; end; Result := ts; -end; - -///-- -{class function TypedSet.operator implicit(a: array of T): TypedSet; -begin - var ts := new TypedSet(); - foreach key: T in a do - begin - ts.ht[key] := key; - end; - Result := ts; end;} ///--