diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 3c2635111..7d8328a56 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "1"; public const string Build = "0"; - public const string Revision = "1207"; + public const string Revision = "1211"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index c535f6439..0b5abe4a6 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %COREVERSION%=0 -%REVISION%=1207 +%REVISION%=1211 %MINOR%=1 %MAJOR%=3 diff --git a/Localization/DefaultLang.resources b/Localization/DefaultLang.resources index 2c5cd4b53..fa0357668 100644 Binary files a/Localization/DefaultLang.resources and b/Localization/DefaultLang.resources differ diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index de04e9675..ccfcebf2c 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: SSM -// DateTime: 16.03.2016 1:44:10 +// DateTime: 03.04.2016 21:59:35 // UserName: ????????? // GPLEX input file // GPLEX frame file diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y index bce928e16..50e28a3c4 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y @@ -1932,6 +1932,8 @@ proc_func_decl_noclass } | tkProcedure proc_name fp_list tkAssign unlabelled_stmt tkSemiColon { + if ($5 is empty_statement) + parsertools.AddErrorFromResource("EMPTY_STATEMENT_IN_SHORT_PROC_DEFINITION",@6); $$ = SyntaxTreeBuilder.BuildShortProcDefinition($3 as formal_parameters, new procedure_attributes_list(), $2 as method_name, $5 as statement, @1.Merge(@3)); } | proc_func_header tkForward tkSemiColon @@ -2782,7 +2784,7 @@ simple_expr_or_nothing } | { - $$ = null; + $$ = new int32_const(int.MaxValue); } ; @@ -2791,9 +2793,9 @@ format_expr { $$ = new format_expr($1, $3, null, @$); } - | tkColon simple_expr + | tkColon simple_expr_or_nothing { - $$ = new format_expr(null, $2, null, @$); + $$ = new format_expr(new int32_const(int.MaxValue), $2, null, @$); } | simple_expr tkColon simple_expr_or_nothing tkColon simple_expr { @@ -2801,7 +2803,7 @@ format_expr } | tkColon simple_expr_or_nothing tkColon simple_expr { - $$ = new format_expr(null, $2, $4, @$); + $$ = new format_expr(new int32_const(int.MaxValue), $2, $4, @$); } ; diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index aaa9d435e..f153bd874 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs @@ -2,7 +2,7 @@ // GPPG version 1.3.6 // Machine: SSM -// DateTime: 16.03.2016 1:44:11 +// DateTime: 03.04.2016 21:59:36 // UserName: ????????? // Input file @@ -74,7 +74,7 @@ public partial class GPPGParser: ShiftReduceParser aliasses; #pragma warning restore 649 private static Rule[] rules = new Rule[794]; - private static State[] states = new State[1263]; + private static State[] states = new State[1262]; private static string[] nonTerms = new string[] { "parse_goal", "unit_key_word", "assignment", "optional_array_initializer", "attribute_declarations", "ot_visibility_specifier", "one_attribute", "attribute_variable", @@ -150,13 +150,13 @@ public partial class GPPGParser: ShiftReduceParser tkProcedure, proc_name, fp_list, tkAssign, // unlabelled_stmt, tkSemiColon { + if (ValueStack[ValueStack.Depth-2].stn is empty_statement) + parsertools.AddErrorFromResource("EMPTY_STATEMENT_IN_SHORT_PROC_DEFINITION",LocationStack[LocationStack.Depth-1]); CurrentSemanticValue.stn = SyntaxTreeBuilder.BuildShortProcDefinition(ValueStack[ValueStack.Depth-4].stn as formal_parameters, new procedure_attributes_list(), ValueStack[ValueStack.Depth-5].stn as method_name, ValueStack[ValueStack.Depth-2].stn as statement, LocationStack[LocationStack.Depth-6].Merge(LocationStack[LocationStack.Depth-4])); } break; @@ -4667,7 +4668,7 @@ public partial class GPPGParser: ShiftReduceParser /* empty */ { - CurrentSemanticValue.ex = null; + CurrentSemanticValue.ex = new int32_const(int.MaxValue); } break; case 553: // format_expr -> simple_expr, tkColon, simple_expr_or_nothing @@ -4675,9 +4676,9 @@ public partial class GPPGParser: ShiftReduceParser tkColon, simple_expr + case 554: // format_expr -> tkColon, simple_expr_or_nothing { - CurrentSemanticValue.ex = new format_expr(null, ValueStack[ValueStack.Depth-1].ex, null, CurrentLocationSpan); + CurrentSemanticValue.ex = new format_expr(new int32_const(int.MaxValue), ValueStack[ValueStack.Depth-1].ex, null, CurrentLocationSpan); } break; case 555: // format_expr -> simple_expr, tkColon, simple_expr_or_nothing, tkColon, @@ -4688,7 +4689,7 @@ public partial class GPPGParser: ShiftReduceParser tkColon, simple_expr_or_nothing, tkColon, simple_expr { - CurrentSemanticValue.ex = new format_expr(null, ValueStack[ValueStack.Depth-3].ex, ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); + CurrentSemanticValue.ex = new format_expr(new int32_const(int.MaxValue), ValueStack[ValueStack.Depth-3].ex, ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; case 557: // relop -> tkEqual diff --git a/Parsers/PascalABCParserNewSaushkin/PABC.ymc b/Parsers/PascalABCParserNewSaushkin/PABC.ymc index 97588e9a8..280f50291 100644 --- a/Parsers/PascalABCParserNewSaushkin/PABC.ymc +++ b/Parsers/PascalABCParserNewSaushkin/PABC.ymc @@ -123,6 +123,8 @@ script= + + diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 80e56caef..b6f90c3f9 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.1.0.1207' +!define VERSION '3.1.0.1211' diff --git a/SyntaxTree/tree/TreeSubsidiary.cs b/SyntaxTree/tree/TreeSubsidiary.cs index 4ac900152..1ea604c3b 100644 --- a/SyntaxTree/tree/TreeSubsidiary.cs +++ b/SyntaxTree/tree/TreeSubsidiary.cs @@ -265,9 +265,12 @@ namespace PascalABCCompiler.SyntaxTree _begin_position = _end_position; if (right == null) _end_position = _begin_position; - this._begin_symbol_position = left._begin_symbol_position; - this._end_symbol_position = right._end_symbol_position; - this.FileName = left.FileName == right.FileName ? left.FileName : null; + if (left != null) + this._begin_symbol_position = left._begin_symbol_position; + if (right != null) + this._end_symbol_position = right._end_symbol_position; + if (left != null && right != null) + this.FileName = left.FileName == right.FileName ? left.FileName : null; } public SourceContext Merge(SourceContext right) diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 9d807991c..a8fb71b3b 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -1609,19 +1609,23 @@ function Rec(x1: T1; x2: T2; x3: T3; x4: T4; x5: T5; x6: T6): function Rec(x1: T1; x2: T2; x3: T3; x4: T4; x5: T5; x6: T6; x7: T7): (T1,T2,T3,T4,T5,T6,T7); // ----------------------------------------------------- -//>> Короткие функции Lst, HSet, SSet, Dict, KV # Short functions Lst, HSet, SSet, Dict, KV +//>> Короткие функции Lst, LLst, HSet, SSet, Dict, KV # Short functions Lst, HSet, SSet, Dict, KV // ----------------------------------------------------- /// Возвращает список, заполненный указанными значениями function Lst(params a: array of T): List; -/// Возвращает список, заполненное значениями из последовательности +/// Возвращает список, заполненный значениями из последовательности function Lst(a: sequence of T): List; +/// Возвращает двусвязный список, заполненный указанными значениями +function LLst(params a: array of T): LinkedList; +/// Возвращает двусвязный список, заполненный значениями из последовательности +function LLst(a: sequence of T): LinkedList; /// Возвращает множество на базе хеш таблицы, заполненное указанными значениями function HSet(params a: array of T): HashSet; -/// Возвращает множество на базе бинарного дерева поиска, заполненное значениями из последовательности -function SSet(params a: array of T): SortedSet; /// Возвращает множество на базе хеш таблицы, заполненное значениями из последовательности function HSet(a: sequence of T): HashSet; /// Возвращает множество на базе бинарного дерева поиска, заполненное значениями из последовательности +function SSet(params a: array of T): SortedSet; +/// Возвращает множество на базе бинарного дерева поиска, заполненное значениями из последовательности function SSet(a: sequence of T): SortedSet; /// Возвращает словарь пар элементов (ключ, значение) function Dict(params pairs: array of KeyValuePair): Dictionary; @@ -4028,7 +4032,7 @@ begin end; // ----------------------------------------------------------------------------- -// Функции Lst, Dict, KV, HSet, SSet +// Функции Lst, LLst, Dict, KV, HSet, SSet // ----------------------------------------------------------------------------- function Lst(params a: array of T): List; begin @@ -4040,6 +4044,16 @@ begin Result := new List(a); end; +function LLst(params a: array of T): LinkedList; +begin + Result := new LinkedList(a); +end; + +function LLst(a: sequence of T): LinkedList; +begin + Result := new LinkedList(a); +end; + function HSet(params a: array of T): HashSet; begin Result := new HashSet(a); @@ -7914,6 +7928,12 @@ begin Result := new SortedSet(Self); end; +/// Возвращает LinkedList по данной последовательности +function ToLinkedList(Self: sequence of T): LinkedList; extensionmethod; +begin + Result := new LinkedList(Self); +end; + // Дополнения февраль 2016: MinBy, MaxBy, TakeLast, Slice, Cartesian, SplitAt, // Partition, ZipTuple, UnZipTuple, Interleave, Numerate, Tabulate, Pairwise, Batch @@ -8116,6 +8136,7 @@ begin Result := SeqWhile(Self,v->v.Skip(size),v->v.Count>0).Select(v->v.Take(size)).Select(ss->proj(ss)); end; +///-- function SliceSeqImpl(Self: sequence of T; from,step,count: integer): sequence of T; begin if step <= 0 then @@ -8127,27 +8148,9 @@ begin Result := Self.Skip(from).Where((x,i)->i mod step = 0) end; - -/// Возвращает срез последовательности от номера from с шагом step +/// Возвращает срез последовательности от номера from с шагом step > 0 function Slice(Self: sequence of T; from,step: integer): sequence of T; extensionmethod; begin - {if step=0 then - raise new ArgumentException(GetTranslation(PARAMETER_STEP_MUST_BE_NOT_EQUAL_0)); - if step<0 then - begin - if from<0 then - Result := Self.Take(0) - else - begin - step := -step; - var bb := from mod step; - Result := Self.Skip(bb).Where((x,i)->(i mod step = 0) and (i<=from-bb)).Reverse; - end; - end - else - if from<=0 then - Result := Self.Where((x,i)->(i-from) mod step = 0) - else Result := Self.Skip(from).Where((x,i)->i mod step = 0);} if step <= 0 then raise new ArgumentException(GetTranslation(PARAMETER_STEP_MUST_BE_GREATER_0)); @@ -8157,34 +8160,9 @@ begin Result := Self.Skip(from).Where((x,i)->i mod step = 0) end; -/// Возвращает срез последовательности от номера from с шагом step длины не более count +/// Возвращает срез последовательности от номера from с шагом step > 0 длины не более count function Slice(Self: sequence of T; from,step,count: integer): sequence of T; extensionmethod; begin - {if step=0 then - raise new ArgumentException(GetTranslation(PARAMETER_STEP_MUST_BE_NOT_EQUAL_0)); - if step<0 then - begin - if from<0 then - Result := Self.Take(0) - else - begin - step := -step; - var bb := from - (count - 1)*step; - if bb<0 then - bb := bb mod step; - if bb < 0 then - bb += step; - Result := Self.Skip(bb).Where((x,i)->(i mod step = 0) and (i<=from-bb)).Reverse; - end; - end - else - if from<0 then - begin - count -= abs(from+1) div step + 1; - Result := Self.Where((x,i)->(i-from) mod step = 0).Take(count) - end - else Result := Self.Skip(from).Where((x,i)->i mod step = 0).Take(count);} - if step <= 0 then raise new ArgumentException(GetTranslation(PARAMETER_STEP_MUST_BE_GREATER_0)); @@ -8225,6 +8203,7 @@ begin end; end; +///-- procedure CorrectCountForSlice(Len,from,step: integer; var count: integer); begin if step = 0 then @@ -8289,11 +8268,13 @@ begin if step = 0 then raise new ArgumentException(GetTranslation(PARAMETER_STEP_MUST_BE_NOT_EQUAL_0)); - if (from < 0) or (from > Len - 1) then - raise new ArgumentException(GetTranslation(PARAMETER_FROM_OUT_OF_RANGE)); + if (situation=0) or (situation=2) then + if (from < 0) or (from > Len - 1) then + raise new ArgumentException(GetTranslation(PARAMETER_FROM_OUT_OF_RANGE)); - if (&to < -1) or (&to > Len) then - raise new ArgumentException(GetTranslation(PARAMETER_TO_OUT_OF_RANGE)); + if (situation=0) or (situation=1) then + if (&to < -1) or (&to > Len) then + raise new ArgumentException(GetTranslation(PARAMETER_TO_OUT_OF_RANGE)); var count: integer; @@ -8507,6 +8488,7 @@ begin end; end; +///-- function SliceArrayImpl(Self: array of T; from,step,count: integer): array of T; begin {if step = 0 then @@ -8855,7 +8837,7 @@ begin Result := res.ToString; end; - +///-- function SliceStringImpl(Self: string; from,step,count: integer): string; begin {if step = 0 then diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 9961bc4e5..01468bb4a 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -18929,14 +18929,6 @@ namespace PascalABCCompiler.TreeConverter public override void visit(SyntaxTree.slice_expr sl) { - // Устарело - // Преобразуется в вызов a.Slice - // from, step сохраняются, count вычисляется как count = (to-from+step-sign(step)) div step - // Для a: нужно to присвоить очень большое целое - // Для :b нужно from присвоить -1 - // Для a::step нужно использовать a.Slice(from,step) - // Для :b:step нужно закодировать from - from := -MaxInt div 2 и в методе Slice это проверить и поправить from в зависимости от знака step - // Новое // Последовательности исключены // Преобразуется в вызов a.SystemSlice(situation,from,to,step) @@ -18944,155 +18936,47 @@ namespace PascalABCCompiler.TreeConverter // situation = 1 - пропущен from // situation = 2 - пропущен to // situation = 3 - пропущены from и to + // пропущенность кодируется тем, что в соответствующем поле int.MaxValue var semvar = convert_strong(sl.v); + if (semvar is typed_expression) + semvar = convert_typed_expression_to_function_call(semvar as typed_expression); + var semvartype = semvar.type; // semvartype должен быть array of T, List или string - var IsSlicedType = false; // проверим, является ли semvartype интерфейсом IEnumerable или реализует его + var IsSlicedType = 0; // проверим, является ли semvartype динамическим массивом, списком List или строкой var t = ConvertSemanticTypeNodeToNETType(semvartype); if (t.IsArray) - IsSlicedType = true; + IsSlicedType = 1; else if (t == typeof(System.String)) - IsSlicedType = true; + IsSlicedType = 2; else if (t.IsGenericType && t.GetGenericTypeDefinition()==typeof(System.Collections.Generic.List<>)) - IsSlicedType = true; + IsSlicedType = 3; - /*var ct = semvartype as compiled_type_node; - if (ct != null && ct.compiled_type.IsGenericType && ct.compiled_type.GetGenericTypeDefinition() == typeof(System.Collections.Generic.IEnumerable<>)) // это он и есть - IsSlicedType = true; - - if (!IsSlicedType) - foreach (SemanticTree.ITypeNode itn in semvartype.ImplementingInterfaces) // Ищем интерфейс IEnumerable - { - if (itn is compiled_generic_instance_type_node) - { - var itnc = (itn as compiled_generic_instance_type_node); - var tt = (itnc.original_generic as compiled_type_node).compiled_type; - - if (tt == typeof(System.Collections.Generic.IEnumerable<>)) - { - IsSlicedType = true; - break; - } - } - else if (itn is compiled_type_node) - { - var itnc = (itn as compiled_type_node); - var tt = itnc.compiled_type; - if (!tt.IsGenericType) - continue; - var tt1 = tt.GetGenericTypeDefinition(); - - if (tt1 == typeof(System.Collections.Generic.IEnumerable<>)) - { - IsSlicedType = true; - break; - } - } - } - - */ - - if (!IsSlicedType) + if (IsSlicedType==0) AddError(get_location(sl.v), "BAD_SLICE_OBJECT"); int situation = 0; - if (sl.from == null && sl.to != null) - situation = 1; - else if (sl.from != null && sl.to == null) - situation = 2; - else if (sl.from == null && sl.to == null) - situation = 3; - var zero = new int32_const(0); - - // заполняем пустые чем-нибудь - if (sl.from == null) - sl.from = zero; - if (sl.to == null) - sl.to = zero; - if (sl.step == null) - sl.step = new int32_const(1); + if ((sl.from is int32_const) && (sl.from as int32_const).val==int.MaxValue) + situation += 1; + if ((sl.to is int32_const) && (sl.to as int32_const).val == int.MaxValue) + situation += 2; var el = new SyntaxTree.expression_list(); el.Add(new int32_const(situation)); el.Add(sl.from); el.Add(sl.to); - el.Add(sl.step); + + if (sl.step != null) + el.Add(sl.step); var mc = new method_call(new dot_node(sl.v, new ident("SystemSlice", sl.v.source_context), sl.v.source_context), el, sl.source_context); visit(mc); - /* - // Ситуация from::step - вызвать Slice с двумя параметрами - пропустить вычисление и добавление count - bool SituationFromSpaceStep = (sl.from != null) && (sl.to == null) && (sl.step != null); - // Ситуация :to:step - закодировать from = -MaxInt div 2 и в Slice сделато коррекцию если step<0 !!! - bool SituationSpaceToStep = (sl.from == null) && (sl.to != null) && (sl.step != null); - - - SyntaxTree.expression synfrom; - if (sl.from != null) - { - var semfrom = convert_strong(sl.from); - convertion_data_and_alghoritms.check_convert_type(semfrom, SystemLibrary.SystemLibrary.integer_type, get_location(sl.from)); - synfrom = new SyntaxTree.semantic_addr_value(semfrom); - } - else - { - synfrom = new int32_const(-1); - } - - var int1 = new int32_const(1); - var el = new SyntaxTree.expression_list(); - - if (semvartype == SystemLibrary.SystemLibrary.string_type) // Сдвинуть from на 1 - el.Add(new bin_expr(synfrom, int1, Operators.Minus)); - else el.Add(synfrom); - - SyntaxTree.expression synstep; - if (sl.step != null) - { - var semstep = convert_strong(sl.step); - convertion_data_and_alghoritms.check_convert_type(semstep, SystemLibrary.SystemLibrary.integer_type, get_location(sl.step)); - synstep = new SyntaxTree.semantic_addr_value(semstep); - } - else - { - synstep = int1; - } - el.Add(synstep); - - SyntaxTree.expression synto; - if (sl.to != null) - { - var semto = convert_strong(sl.to); - convertion_data_and_alghoritms.check_convert_type(semto, SystemLibrary.SystemLibrary.integer_type, get_location(sl.to)); - synto = new SyntaxTree.semantic_addr_value(semto); - } - else - { - synto = new int32_const(Int32.MaxValue/2); - } - - if (!SituationFromSpaceStep) // если не from::step то вычислить count и вызвать Slice с тремя параметрами - { - // count = (to-from+step-sign(step)) div step - SyntaxTree.expression ex = new bin_expr(synto, synfrom, Operators.Minus); - SyntaxTree.expression signstep = new method_call(new ident("sign"), new expression_list(synstep)); - ex = new bin_expr(ex, synstep, Operators.Plus); - ex = new bin_expr(ex, signstep, Operators.Minus); - ex = new bin_expr(ex, synstep, Operators.IntegerDivision); - - el.Add(ex); // Параметр count - } - - var mc = new method_call(new dot_node(sl.v, new ident("Slice", sl.v.source_context), sl.v.source_context), el, sl.source_context); - visit(mc); - */ - } /*public SyntaxTree.question_colon_expression ConvertToQCE(dot_question_node dqn) diff --git a/_Presentations/2015 New Features/Programs/06_ShortFunc.pas b/_Presentations/2015 New Features/Programs/06_ShortFunc.pas index 956743db3..ed784d57d 100644 --- a/_Presentations/2015 New Features/Programs/06_ShortFunc.pas +++ b/_Presentations/2015 New Features/Programs/06_ShortFunc.pas @@ -8,7 +8,13 @@ function Len(x1,y1,x2,y2: real) := Hypot(x2-x1,y2-y1); function DigitCount(x: integer) := abs(x).ToString.Length; +function (a,b,c: real): real := Min(Min(a,b),c); + +procedure <>(x: ) := Println(x); + begin - writeln(Hypot(3,4)); - writeln(DigitCount(-1234)); + Println(Sqr3(2),CircleLen(1)); + Println(Hypot(3,4),Len(1,1,3,4)); + Println(DigitCount(-1234)); + ((5,3,8)); end. \ No newline at end of file diff --git a/_Presentations/2015 New Features/Programs/QuickSortLinq3.pas b/_Presentations/2015 New Features/Programs/QuickSortLinq3.pas index 80fc809c2..89c8637aa 100644 --- a/_Presentations/2015 New Features/Programs/QuickSortLinq3.pas +++ b/_Presentations/2015 New Features/Programs/QuickSortLinq3.pas @@ -1,6 +1,9 @@ function QuickSort(a: sequence of integer): sequence of integer; begin - Result := a.Count = 0 ? a : QuickSort(a.Skip(1).Where(x->x<=a.First())) + a.First() + QuickSort(a.Skip(1).Where(x->x>a.First())); + Result := a.Count = 0 ? a : + QuickSort(a.Skip(1).Where(x -> x <= a.First)) + + a.First + + QuickSort(a.Skip(1).Where(x -> x > a.First)); end; begin diff --git a/bin/Lib/PABCRtl.dll b/bin/Lib/PABCRtl.dll index de451bc8b..bdaf16e66 100644 Binary files a/bin/Lib/PABCRtl.dll and b/bin/Lib/PABCRtl.dll differ diff --git a/bin/Lib/PABCSystem.axml b/bin/Lib/PABCSystem.axml index fce30267b..03c817fe6 100644 --- a/bin/Lib/PABCSystem.axml +++ b/bin/Lib/PABCSystem.axml @@ -2459,9 +2459,9 @@ \PABCSystem.pas - function SystemSliceListImpl<T>(Self: List<T>; situation: integer; from,&to: integer; step: integer := 1): List<T>; + function SystemSliceArrayImpl<T>(Self: array of T; situation: integer; from,&to: integer; step: integer := 1): array of T; - function SystemSliceListImpl < T > ( Self : List < T > ; situation : integer ; from , &to : integer ; step : integer : = 1 ) : List < T > + function SystemSliceArrayImpl < T > ( Self : array of T ; situation : integer ; from , &to : integer ; step : integer : = 1 ) : array of T diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index 9d807991c..a8fb71b3b 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -1609,19 +1609,23 @@ function Rec(x1: T1; x2: T2; x3: T3; x4: T4; x5: T5; x6: T6): function Rec(x1: T1; x2: T2; x3: T3; x4: T4; x5: T5; x6: T6; x7: T7): (T1,T2,T3,T4,T5,T6,T7); // ----------------------------------------------------- -//>> Короткие функции Lst, HSet, SSet, Dict, KV # Short functions Lst, HSet, SSet, Dict, KV +//>> Короткие функции Lst, LLst, HSet, SSet, Dict, KV # Short functions Lst, HSet, SSet, Dict, KV // ----------------------------------------------------- /// Возвращает список, заполненный указанными значениями function Lst(params a: array of T): List; -/// Возвращает список, заполненное значениями из последовательности +/// Возвращает список, заполненный значениями из последовательности function Lst(a: sequence of T): List; +/// Возвращает двусвязный список, заполненный указанными значениями +function LLst(params a: array of T): LinkedList; +/// Возвращает двусвязный список, заполненный значениями из последовательности +function LLst(a: sequence of T): LinkedList; /// Возвращает множество на базе хеш таблицы, заполненное указанными значениями function HSet(params a: array of T): HashSet; -/// Возвращает множество на базе бинарного дерева поиска, заполненное значениями из последовательности -function SSet(params a: array of T): SortedSet; /// Возвращает множество на базе хеш таблицы, заполненное значениями из последовательности function HSet(a: sequence of T): HashSet; /// Возвращает множество на базе бинарного дерева поиска, заполненное значениями из последовательности +function SSet(params a: array of T): SortedSet; +/// Возвращает множество на базе бинарного дерева поиска, заполненное значениями из последовательности function SSet(a: sequence of T): SortedSet; /// Возвращает словарь пар элементов (ключ, значение) function Dict(params pairs: array of KeyValuePair): Dictionary; @@ -4028,7 +4032,7 @@ begin end; // ----------------------------------------------------------------------------- -// Функции Lst, Dict, KV, HSet, SSet +// Функции Lst, LLst, Dict, KV, HSet, SSet // ----------------------------------------------------------------------------- function Lst(params a: array of T): List; begin @@ -4040,6 +4044,16 @@ begin Result := new List(a); end; +function LLst(params a: array of T): LinkedList; +begin + Result := new LinkedList(a); +end; + +function LLst(a: sequence of T): LinkedList; +begin + Result := new LinkedList(a); +end; + function HSet(params a: array of T): HashSet; begin Result := new HashSet(a); @@ -7914,6 +7928,12 @@ begin Result := new SortedSet(Self); end; +/// Возвращает LinkedList по данной последовательности +function ToLinkedList(Self: sequence of T): LinkedList; extensionmethod; +begin + Result := new LinkedList(Self); +end; + // Дополнения февраль 2016: MinBy, MaxBy, TakeLast, Slice, Cartesian, SplitAt, // Partition, ZipTuple, UnZipTuple, Interleave, Numerate, Tabulate, Pairwise, Batch @@ -8116,6 +8136,7 @@ begin Result := SeqWhile(Self,v->v.Skip(size),v->v.Count>0).Select(v->v.Take(size)).Select(ss->proj(ss)); end; +///-- function SliceSeqImpl(Self: sequence of T; from,step,count: integer): sequence of T; begin if step <= 0 then @@ -8127,27 +8148,9 @@ begin Result := Self.Skip(from).Where((x,i)->i mod step = 0) end; - -/// Возвращает срез последовательности от номера from с шагом step +/// Возвращает срез последовательности от номера from с шагом step > 0 function Slice(Self: sequence of T; from,step: integer): sequence of T; extensionmethod; begin - {if step=0 then - raise new ArgumentException(GetTranslation(PARAMETER_STEP_MUST_BE_NOT_EQUAL_0)); - if step<0 then - begin - if from<0 then - Result := Self.Take(0) - else - begin - step := -step; - var bb := from mod step; - Result := Self.Skip(bb).Where((x,i)->(i mod step = 0) and (i<=from-bb)).Reverse; - end; - end - else - if from<=0 then - Result := Self.Where((x,i)->(i-from) mod step = 0) - else Result := Self.Skip(from).Where((x,i)->i mod step = 0);} if step <= 0 then raise new ArgumentException(GetTranslation(PARAMETER_STEP_MUST_BE_GREATER_0)); @@ -8157,34 +8160,9 @@ begin Result := Self.Skip(from).Where((x,i)->i mod step = 0) end; -/// Возвращает срез последовательности от номера from с шагом step длины не более count +/// Возвращает срез последовательности от номера from с шагом step > 0 длины не более count function Slice(Self: sequence of T; from,step,count: integer): sequence of T; extensionmethod; begin - {if step=0 then - raise new ArgumentException(GetTranslation(PARAMETER_STEP_MUST_BE_NOT_EQUAL_0)); - if step<0 then - begin - if from<0 then - Result := Self.Take(0) - else - begin - step := -step; - var bb := from - (count - 1)*step; - if bb<0 then - bb := bb mod step; - if bb < 0 then - bb += step; - Result := Self.Skip(bb).Where((x,i)->(i mod step = 0) and (i<=from-bb)).Reverse; - end; - end - else - if from<0 then - begin - count -= abs(from+1) div step + 1; - Result := Self.Where((x,i)->(i-from) mod step = 0).Take(count) - end - else Result := Self.Skip(from).Where((x,i)->i mod step = 0).Take(count);} - if step <= 0 then raise new ArgumentException(GetTranslation(PARAMETER_STEP_MUST_BE_GREATER_0)); @@ -8225,6 +8203,7 @@ begin end; end; +///-- procedure CorrectCountForSlice(Len,from,step: integer; var count: integer); begin if step = 0 then @@ -8289,11 +8268,13 @@ begin if step = 0 then raise new ArgumentException(GetTranslation(PARAMETER_STEP_MUST_BE_NOT_EQUAL_0)); - if (from < 0) or (from > Len - 1) then - raise new ArgumentException(GetTranslation(PARAMETER_FROM_OUT_OF_RANGE)); + if (situation=0) or (situation=2) then + if (from < 0) or (from > Len - 1) then + raise new ArgumentException(GetTranslation(PARAMETER_FROM_OUT_OF_RANGE)); - if (&to < -1) or (&to > Len) then - raise new ArgumentException(GetTranslation(PARAMETER_TO_OUT_OF_RANGE)); + if (situation=0) or (situation=1) then + if (&to < -1) or (&to > Len) then + raise new ArgumentException(GetTranslation(PARAMETER_TO_OUT_OF_RANGE)); var count: integer; @@ -8507,6 +8488,7 @@ begin end; end; +///-- function SliceArrayImpl(Self: array of T; from,step,count: integer): array of T; begin {if step = 0 then @@ -8855,7 +8837,7 @@ begin Result := res.ToString; end; - +///-- function SliceStringImpl(Self: string; from,step,count: integer): string; begin {if step = 0 then diff --git a/bin/Lng/Eng/PascalABCParser.dat b/bin/Lng/Eng/PascalABCParser.dat index c78aaff6a..a3ef1413b 100644 --- a/bin/Lng/Eng/PascalABCParser.dat +++ b/bin/Lng/Eng/PascalABCParser.dat @@ -50,6 +50,8 @@ ONE_OPERATOR=Expected operator ONE_STMT=Expected statement BAD_TUPLE=Badly formed Tuple TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7=Count of Tuple elements must be <=7 +EMPTY_STATEMENT_IN_SHORT_PROC_DEFINITION=Statement expected + DUPLICATE_NAMES_IN_ANON_TYPE=Duplicate field names in anonymous type BAD_ANON_TYPE=Bad field name in anonymous type diff --git a/bin/Lng/Eng/SemanticErrors_ms.dat b/bin/Lng/Eng/SemanticErrors_ms.dat index 1708d80c3..bfa254f27 100644 --- a/bin/Lng/Eng/SemanticErrors_ms.dat +++ b/bin/Lng/Eng/SemanticErrors_ms.dat @@ -5,4 +5,4 @@ TOO_MANY_ELEMENTS_ON_LEFT_SIDE_OF_TUPLE_ASSIGNMRNT=Too many elements on the left ONLY_BASE_ASSIGNMENT_FOR_TUPLE=Tuple allows only base assignment := TUPLE_TYPE_ERROR=Bad element in Tuple type INTEGER_VALUE_EXPECTED=Integer value expected -BAD_SLICE_OBJECT=Slices are allowed for strings, dynamic arrays, lists and sequences only +BAD_SLICE_OBJECT=Slices are allowed for strings, dynamic arrays and lists only diff --git a/bin/Lng/Rus/PascalABCParser.dat b/bin/Lng/Rus/PascalABCParser.dat index a3d72fdce..46dbe1e04 100644 --- a/bin/Lng/Rus/PascalABCParser.dat +++ b/bin/Lng/Rus/PascalABCParser.dat @@ -50,6 +50,7 @@ ONE_OPERATOR=Ожидался оператор ONE_STMT=Ожидался оператор BAD_TUPLE=Неправильно сформированный кортеж TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7=Количество элементов кортежа не должно быть больше 7 +EMPTY_STATEMENT_IN_SHORT_PROC_DEFINITION=Ожидался оператор DUPLICATE_NAMES_IN_ANON_TYPE=Анонимный тип не может содержать поля с одинаковыми именами BAD_ANON_TYPE=Неверное определение имени поля анонимного типа diff --git a/bin/Lng/Rus/SemanticErrors_ms.dat b/bin/Lng/Rus/SemanticErrors_ms.dat index b2f62b732..807b391ba 100644 --- a/bin/Lng/Rus/SemanticErrors_ms.dat +++ b/bin/Lng/Rus/SemanticErrors_ms.dat @@ -5,4 +5,4 @@ TOO_MANY_ELEMENTS_ON_LEFT_SIDE_OF_TUPLE_ASSIGNMRNT=Слишком много э ONLY_BASE_ASSIGNMENT_FOR_TUPLE=Для кортежа допустимо только обычное присваивание := TUPLE_TYPE_ERROR=Ошибочная конструкция при построении типа кортежа INTEGER_VALUE_EXPECTED=Ожидалось значение целого типа -BAD_SLICE_OBJECT=Срезы допустимы только для строк, динамических массивов, списков и последовательностей +BAD_SLICE_OBJECT=Срезы допустимы только для строк, динамических массивов и списков diff --git a/bin/PascalABCNET.chm b/bin/PascalABCNET.chm index 68255b3de..c7205656a 100644 Binary files a/bin/PascalABCNET.chm and b/bin/PascalABCNET.chm differ