Изменение грамматики - запрет условной операции как тела лямбды (во избежание конфликтов с условным оператором)
This commit is contained in:
parent
ecbdc6e1a2
commit
da4406700f
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
||||||
public const string Major = "3";
|
public const string Major = "3";
|
||||||
public const string Minor = "5";
|
public const string Minor = "5";
|
||||||
public const string Build = "1";
|
public const string Build = "1";
|
||||||
public const string Revision = "2300";
|
public const string Revision = "2310";
|
||||||
|
|
||||||
public const string MainVersion = Major + "." + Minor;
|
public const string MainVersion = Major + "." + Minor;
|
||||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
%COREVERSION%=1
|
%COREVERSION%=1
|
||||||
%REVISION%=2300
|
%REVISION%=2310
|
||||||
%MINOR%=5
|
%MINOR%=5
|
||||||
%MAJOR%=3
|
%MAJOR%=3
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// This CSharp output file generated by Gardens Point LEX
|
// This CSharp output file generated by Gardens Point LEX
|
||||||
// Version: 1.1.3.301
|
// Version: 1.1.3.301
|
||||||
// Machine: DESKTOP-G8V08V4
|
// Machine: DESKTOP-G8V08V4
|
||||||
// DateTime: 12.01.2020 19:05:36
|
// DateTime: 13.01.2020 1:44:39
|
||||||
// UserName: ?????????
|
// UserName: ?????????
|
||||||
// GPLEX input file <ABCPascal.lex>
|
// GPLEX input file <ABCPascal.lex>
|
||||||
// GPLEX frame file <embedded resource>
|
// GPLEX frame file <embedded resource>
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,8 @@
|
||||||
%type <stn> typed_const_list1 typed_const_list optional_expr_list elem_list optional_expr_list_with_bracket expr_list const_elem_list1 /*const_func_expr_list*/ case_label_list const_elem_list optional_const_func_expr_list elem_list1
|
%type <stn> typed_const_list1 typed_const_list optional_expr_list elem_list optional_expr_list_with_bracket expr_list const_elem_list1 /*const_func_expr_list*/ case_label_list const_elem_list optional_const_func_expr_list elem_list1
|
||||||
%type <stn> enumeration_id expr_l1_list
|
%type <stn> enumeration_id expr_l1_list
|
||||||
%type <stn> enumeration_id_list
|
%type <stn> enumeration_id_list
|
||||||
%type <ex> const_simple_expr term term1 simple_term typed_const typed_const_plus typed_var_init_expression expr expr_with_func_decl_lambda const_expr elem range_expr const_elem array_const factor relop_expr expr_dq expr_l1 expr_l1_func_decl_lambda simple_expr range_term range_factor
|
%type <ex> const_simple_expr term term1 simple_term typed_const typed_const_plus typed_var_init_expression expr expr_with_func_decl_lambda const_expr elem range_expr const_elem array_const factor relop_expr expr_dq expr_l1 expr_l1_func_decl_lambda expr_l1_for_lambda simple_expr range_term range_factor
|
||||||
%type <ex> external_directive_ident init_const_expr case_label variable var_reference /*optional_write_expr*/ optional_read_expr simple_expr_or_nothing var_question_point
|
%type <ex> external_directive_ident init_const_expr case_label variable var_reference /*optional_write_expr*/ optional_read_expr simple_expr_or_nothing var_question_point expr_l1_for_question_expr expr_l1_for_new_question_expr
|
||||||
%type <ob> for_cycle_type
|
%type <ob> for_cycle_type
|
||||||
%type <ex> format_expr format_const_expr const_expr_or_nothing
|
%type <ex> format_expr format_const_expr const_expr_or_nothing
|
||||||
%type <stn> foreach_stmt
|
%type <stn> foreach_stmt
|
||||||
|
|
@ -134,7 +134,7 @@
|
||||||
%type <stn> parameter_decl
|
%type <stn> parameter_decl
|
||||||
%type <stn> parameter_decl_list property_parameter_list
|
%type <stn> parameter_decl_list property_parameter_list
|
||||||
%type <ex> const_set
|
%type <ex> const_set
|
||||||
%type <ex> question_expr question_constexpr
|
%type <ex> question_expr question_constexpr new_question_expr
|
||||||
%type <ex> record_const const_field_list_1 const_field_list
|
%type <ex> record_const const_field_list_1 const_field_list
|
||||||
%type <stn> const_field
|
%type <stn> const_field
|
||||||
%type <stn> repeat_stmt
|
%type <stn> repeat_stmt
|
||||||
|
|
@ -3124,14 +3124,39 @@ expr_l1
|
||||||
{ $$ = $1; }
|
{ $$ = $1; }
|
||||||
| question_expr
|
| question_expr
|
||||||
{ $$ = $1; }
|
{ $$ = $1; }
|
||||||
|
| new_question_expr
|
||||||
|
{ $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
expr_l1_for_question_expr
|
||||||
|
: expr_dq
|
||||||
|
{ $$ = $1; }
|
||||||
|
| question_expr
|
||||||
|
{ $$ = $1; }
|
||||||
|
;
|
||||||
|
|
||||||
|
expr_l1_for_new_question_expr
|
||||||
|
: expr_dq
|
||||||
|
{ $$ = $1; }
|
||||||
|
| new_question_expr
|
||||||
|
{ $$ = $1; }
|
||||||
|
;
|
||||||
|
|
||||||
expr_l1_func_decl_lambda
|
expr_l1_func_decl_lambda
|
||||||
: expr_l1
|
: expr_l1
|
||||||
{ $$ = $1; }
|
{ $$ = $1; }
|
||||||
| func_decl_lambda
|
| func_decl_lambda
|
||||||
{ $$ = $1; }
|
{ $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
expr_l1_for_lambda
|
||||||
|
: expr_dq
|
||||||
|
{ $$ = $1; }
|
||||||
|
| question_expr
|
||||||
|
{ $$ = $1; }
|
||||||
|
| func_decl_lambda
|
||||||
|
{ $$ = $1; }
|
||||||
|
;
|
||||||
|
|
||||||
expr_dq
|
expr_dq
|
||||||
: relop_expr
|
: relop_expr
|
||||||
|
|
@ -3160,13 +3185,16 @@ typeof_expr
|
||||||
;
|
;
|
||||||
|
|
||||||
question_expr
|
question_expr
|
||||||
: expr_l1 tkQuestion expr_l1 tkColon expr_l1
|
: expr_l1_for_question_expr tkQuestion expr_l1_for_question_expr tkColon expr_l1_for_question_expr
|
||||||
{
|
{
|
||||||
if ($3 is nil_const && $5 is nil_const)
|
if ($3 is nil_const && $5 is nil_const)
|
||||||
parsertools.AddErrorFromResource("TWO_NILS_IN_QUESTION_EXPR",@3);
|
parsertools.AddErrorFromResource("TWO_NILS_IN_QUESTION_EXPR",@3);
|
||||||
$$ = new question_colon_expression($1, $3, $5, @$);
|
$$ = new question_colon_expression($1, $3, $5, @$);
|
||||||
}
|
}
|
||||||
| tkIf expr_dq tkThen expr_l1 tkElse expr_l1
|
;
|
||||||
|
|
||||||
|
new_question_expr
|
||||||
|
: tkIf expr_l1_for_new_question_expr tkThen expr_l1_for_new_question_expr tkElse expr_l1_for_new_question_expr
|
||||||
{
|
{
|
||||||
if (parsertools.build_tree_for_formatter)
|
if (parsertools.build_tree_for_formatter)
|
||||||
{
|
{
|
||||||
|
|
@ -3179,7 +3207,8 @@ question_expr
|
||||||
$$ = new question_colon_expression($2, $4, $6, @$);
|
$$ = new question_colon_expression($2, $4, $6, @$);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
empty_template_type_reference
|
empty_template_type_reference
|
||||||
: simple_type_identifier template_type_empty_params
|
: simple_type_identifier template_type_empty_params
|
||||||
|
|
@ -4684,7 +4713,7 @@ common_lambda_body
|
||||||
|
|
||||||
|
|
||||||
lambda_function_body
|
lambda_function_body
|
||||||
: expr_l1_func_decl_lambda
|
: expr_l1_for_lambda
|
||||||
{
|
{
|
||||||
var id = SyntaxVisitors.ExprHasNameVisitor.HasName($1, "Result");
|
var id = SyntaxVisitors.ExprHasNameVisitor.HasName($1, "Result");
|
||||||
if (id != null)
|
if (id != null)
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -255,6 +255,10 @@ script=
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
3.5.1.2300
|
3.5.1.2310
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
!define VERSION '3.5.1.2300'
|
!define VERSION '3.5.1.2310'
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
begin
|
begin
|
||||||
var p: procedure(x: integer);
|
var p: procedure(x: integer);
|
||||||
p := x -> if True then Print(x);
|
p := procedure(x) -> if True then Print(x);
|
||||||
p(666);
|
p(666);
|
||||||
end.
|
end.
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
begin
|
begin
|
||||||
Arr(1,2,3).ForEach(x -> if x>1 then Print(x));
|
Arr(1,2,3).ForEach(procedure(x) -> if x>1 then Print(x));
|
||||||
end.
|
end.
|
||||||
|
|
@ -628,6 +628,8 @@ function TryRead(var x: single): boolean;
|
||||||
|
|
||||||
/// Возвращает значение типа integer, введенное с клавиатуры
|
/// Возвращает значение типа integer, введенное с клавиатуры
|
||||||
function ReadInteger: integer;
|
function ReadInteger: integer;
|
||||||
|
/// Возвращает значение типа int64, введенное с клавиатуры
|
||||||
|
function ReadInt64: int64;
|
||||||
/// Возвращает значение типа real, введенное с клавиатуры
|
/// Возвращает значение типа real, введенное с клавиатуры
|
||||||
function ReadReal: real;
|
function ReadReal: real;
|
||||||
/// Возвращает значение типа char, введенное с клавиатуры
|
/// Возвращает значение типа char, введенное с клавиатуры
|
||||||
|
|
@ -639,6 +641,8 @@ function ReadBoolean: boolean;
|
||||||
|
|
||||||
/// Возвращает значение типа integer, введенное с клавиатуры, и переходит на следующую строку ввода
|
/// Возвращает значение типа integer, введенное с клавиатуры, и переходит на следующую строку ввода
|
||||||
function ReadlnInteger: integer;
|
function ReadlnInteger: integer;
|
||||||
|
/// Возвращает значение типа int64, введенное с клавиатуры, и переходит на следующую строку ввода
|
||||||
|
function ReadlnInt64: int64;
|
||||||
/// Возвращает значение типа real, введенное с клавиатуры, и переходит на следующую строку ввода
|
/// Возвращает значение типа real, введенное с клавиатуры, и переходит на следующую строку ввода
|
||||||
function ReadlnReal: real;
|
function ReadlnReal: real;
|
||||||
/// Возвращает значение типа char, введенное с клавиатуры, и переходит на следующую строку ввода
|
/// Возвращает значение типа char, введенное с клавиатуры, и переходит на следующую строку ввода
|
||||||
|
|
@ -752,6 +756,8 @@ function ReadlnString4(prompt: string): (string, string, string, string);
|
||||||
|
|
||||||
/// Выводит приглашение к вводу и возвращает значение типа integer, введенное с клавиатуры
|
/// Выводит приглашение к вводу и возвращает значение типа integer, введенное с клавиатуры
|
||||||
function ReadInteger(prompt: string): integer;
|
function ReadInteger(prompt: string): integer;
|
||||||
|
/// Выводит приглашение к вводу и возвращает значение типа int64, введенное с клавиатуры
|
||||||
|
function ReadInt64(prompt: string): int64;
|
||||||
/// Выводит приглашение к вводу и возвращает значение типа real, введенное с клавиатуры
|
/// Выводит приглашение к вводу и возвращает значение типа real, введенное с клавиатуры
|
||||||
function ReadReal(prompt: string): real;
|
function ReadReal(prompt: string): real;
|
||||||
/// Выводит приглашение к вводу и возвращает значение типа char, введенное с клавиатуры
|
/// Выводит приглашение к вводу и возвращает значение типа char, введенное с клавиатуры
|
||||||
|
|
@ -764,6 +770,9 @@ function ReadBoolean(prompt: string): boolean;
|
||||||
/// Выводит приглашение к вводу и возвращает значение типа integer, введенное с клавиатуры,
|
/// Выводит приглашение к вводу и возвращает значение типа integer, введенное с клавиатуры,
|
||||||
///и осуществляет переход на следующую строку ввода
|
///и осуществляет переход на следующую строку ввода
|
||||||
function ReadlnInteger(prompt: string): integer;
|
function ReadlnInteger(prompt: string): integer;
|
||||||
|
/// Выводит приглашение к вводу и возвращает значение типа int64, введенное с клавиатуры,
|
||||||
|
///и осуществляет переход на следующую строку ввода
|
||||||
|
function ReadlnInt64(prompt: string): int64;
|
||||||
/// Выводит приглашение к вводу и возвращает значение типа real, введенное с клавиатуры,
|
/// Выводит приглашение к вводу и возвращает значение типа real, введенное с клавиатуры,
|
||||||
///и осуществляет переход на следующую строку ввода
|
///и осуществляет переход на следующую строку ввода
|
||||||
function ReadlnReal(prompt: string): real;
|
function ReadlnReal(prompt: string): real;
|
||||||
|
|
@ -821,6 +830,8 @@ procedure Readln(f: Text; var x: string);
|
||||||
|
|
||||||
/// Возвращает значение типа integer, введенное из текстового файла f
|
/// Возвращает значение типа integer, введенное из текстового файла f
|
||||||
function ReadInteger(f: Text): integer;
|
function ReadInteger(f: Text): integer;
|
||||||
|
/// Возвращает значение типа int64, введенное из текстового файла f
|
||||||
|
function ReadInt64(f: Text): int64;
|
||||||
/// Возвращает значение типа real, введенное из текстового файла f
|
/// Возвращает значение типа real, введенное из текстового файла f
|
||||||
function ReadReal(f: Text): real;
|
function ReadReal(f: Text): real;
|
||||||
/// Возвращает значение типа char, введенное из текстового файла f
|
/// Возвращает значение типа char, введенное из текстового файла f
|
||||||
|
|
@ -833,6 +844,9 @@ function ReadBoolean(f: Text): boolean;
|
||||||
/// Возвращает значение типа integer, введенное из текстового файла f,
|
/// Возвращает значение типа integer, введенное из текстового файла f,
|
||||||
///и осуществляет переход на следующую строку
|
///и осуществляет переход на следующую строку
|
||||||
function ReadlnInteger(f: Text): integer;
|
function ReadlnInteger(f: Text): integer;
|
||||||
|
/// Возвращает значение типа int64, введенное из текстового файла f,
|
||||||
|
///и осуществляет переход на следующую строку
|
||||||
|
function ReadlnInt64(f: Text): int64;
|
||||||
/// Возвращает значение типа real, введенное из текстового файла f,
|
/// Возвращает значение типа real, введенное из текстового файла f,
|
||||||
///и осуществляет переход на следующую строку
|
///и осуществляет переход на следующую строку
|
||||||
function ReadlnReal(f: Text): real;
|
function ReadlnReal(f: Text): real;
|
||||||
|
|
@ -1913,6 +1927,13 @@ function ReadArrInteger(n: integer): array of integer;
|
||||||
function ReadArrReal(n: integer): array of real;
|
function ReadArrReal(n: integer): array of real;
|
||||||
/// Возвращает массив из n строк, введенных с клавиатуры
|
/// Возвращает массив из n строк, введенных с клавиатуры
|
||||||
function ReadArrString(n: integer): array of string;
|
function ReadArrString(n: integer): array of string;
|
||||||
|
///--
|
||||||
|
function ReadArrInteger: array of integer;
|
||||||
|
///--
|
||||||
|
function ReadArrReal: array of real;
|
||||||
|
///--
|
||||||
|
function ReadArrString: array of string;
|
||||||
|
|
||||||
|
|
||||||
/// Выводит приглашение к вводу и возвращает массив из n целых, введенных с клавиатуры
|
/// Выводит приглашение к вводу и возвращает массив из n целых, введенных с клавиатуры
|
||||||
function ReadArrInteger(prompt: string; n: integer): array of integer;
|
function ReadArrInteger(prompt: string; n: integer): array of integer;
|
||||||
|
|
@ -2035,6 +2056,13 @@ function __WildCardsTupleEqual<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12
|
||||||
elemsToCompare: sequence of integer): boolean;
|
elemsToCompare: sequence of integer): boolean;
|
||||||
|
|
||||||
|
|
||||||
|
// Вспомогательные функции для a..b
|
||||||
|
///--
|
||||||
|
function InRangeInternal(x: integer; a,b: integer): boolean;
|
||||||
|
|
||||||
|
///--
|
||||||
|
function InRangeInternal(x: char; a,b: char): boolean;
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
// Стандартные классы исключений
|
// Стандартные классы исключений
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
@ -4392,6 +4420,26 @@ begin
|
||||||
Result := ReadArrString(n);
|
Result := ReadArrString(n);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
///--
|
||||||
|
function ReadArrInteger: array of integer;
|
||||||
|
begin
|
||||||
|
Result := nil;
|
||||||
|
raise new System.ArgumentException('Функцию ReadArrInteger запрещено вызывать без параметров')
|
||||||
|
end;
|
||||||
|
///--
|
||||||
|
function ReadArrReal: array of real;
|
||||||
|
begin
|
||||||
|
Result := nil;
|
||||||
|
raise new System.ArgumentException('Функцию ReadArrReal запрещено вызывать без параметров')
|
||||||
|
end;
|
||||||
|
///--
|
||||||
|
function ReadArrString: array of string;
|
||||||
|
begin
|
||||||
|
Result := nil;
|
||||||
|
raise new System.ArgumentException('Функцию ReadArrString запрещено вызывать без параметров')
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function ReadSeqInteger(n: integer): sequence of integer;
|
function ReadSeqInteger(n: integer): sequence of integer;
|
||||||
begin
|
begin
|
||||||
Result := Range(1, n).Select(i -> ReadInteger());
|
Result := Range(1, n).Select(i -> ReadInteger());
|
||||||
|
|
@ -5213,59 +5261,59 @@ begin
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function ReadInteger: integer;
|
function ReadInteger: integer;
|
||||||
begin
|
begin
|
||||||
var x: integer;
|
Read(Result);
|
||||||
read(x);
|
end;
|
||||||
Result := x;
|
|
||||||
|
function ReadInt64: int64;
|
||||||
|
begin
|
||||||
|
Read(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadReal: real;
|
function ReadReal: real;
|
||||||
begin
|
begin
|
||||||
var x: real;
|
Read(Result);
|
||||||
read(x);
|
|
||||||
Result := x;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadChar: char;
|
function ReadChar: char;
|
||||||
begin
|
begin
|
||||||
var x: char;
|
Read(Result);
|
||||||
read(x);
|
|
||||||
Result := x;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadString: string;
|
function ReadString: string;
|
||||||
begin
|
begin
|
||||||
var x: string;
|
Read(Result);
|
||||||
read(x);
|
|
||||||
readln();
|
readln();
|
||||||
Result := x;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadBoolean: boolean;
|
function ReadBoolean: boolean;
|
||||||
begin
|
begin
|
||||||
var x: boolean;
|
Read(Result);
|
||||||
read(x);
|
|
||||||
Result := x;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadlnInteger: integer;
|
function ReadlnInteger: integer;
|
||||||
begin
|
begin
|
||||||
Result := ReadInteger;
|
Result := ReadInteger;
|
||||||
readln();
|
Readln();
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ReadlnInt64: int64;
|
||||||
|
begin
|
||||||
|
Result := ReadInt64;
|
||||||
|
Readln();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadlnReal: real;
|
function ReadlnReal: real;
|
||||||
begin
|
begin
|
||||||
Result := ReadReal;
|
Result := ReadReal;
|
||||||
readln();
|
Readln();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadlnChar: char;
|
function ReadlnChar: char;
|
||||||
begin
|
begin
|
||||||
Result := ReadChar;
|
Result := ReadChar;
|
||||||
readln();
|
Readln();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadlnString: string;
|
function ReadlnString: string;
|
||||||
|
|
@ -5276,7 +5324,7 @@ end;
|
||||||
function ReadlnBoolean: boolean;
|
function ReadlnBoolean: boolean;
|
||||||
begin
|
begin
|
||||||
Result := ReadBoolean;
|
Result := ReadBoolean;
|
||||||
readln();
|
Readln();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadInteger2 := (ReadInteger, ReadInteger);
|
function ReadInteger2 := (ReadInteger, ReadInteger);
|
||||||
|
|
@ -5388,6 +5436,12 @@ begin
|
||||||
Result := ReadInteger;
|
Result := ReadInteger;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ReadInt64(prompt: string): int64;
|
||||||
|
begin
|
||||||
|
Print(prompt);
|
||||||
|
Result := ReadInt64;
|
||||||
|
end;
|
||||||
|
|
||||||
function ReadReal(prompt: string): real;
|
function ReadReal(prompt: string): real;
|
||||||
begin
|
begin
|
||||||
Print(prompt);
|
Print(prompt);
|
||||||
|
|
@ -5418,6 +5472,12 @@ begin
|
||||||
Result := ReadlnInteger;
|
Result := ReadlnInteger;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ReadlnInt64(prompt: string): int64;
|
||||||
|
begin
|
||||||
|
Print(prompt);
|
||||||
|
Result := ReadlnInt64;
|
||||||
|
end;
|
||||||
|
|
||||||
function ReadlnReal(prompt: string): real;
|
function ReadlnReal(prompt: string): real;
|
||||||
begin
|
begin
|
||||||
Print(prompt);
|
Print(prompt);
|
||||||
|
|
@ -5674,56 +5734,57 @@ end;
|
||||||
|
|
||||||
function ReadInteger(f: Text): integer;
|
function ReadInteger(f: Text): integer;
|
||||||
begin
|
begin
|
||||||
var x: integer;
|
Read(f, Result);
|
||||||
read(f, x);
|
end;
|
||||||
Result := x;
|
|
||||||
|
function ReadInt64(f: Text): int64;
|
||||||
|
begin
|
||||||
|
Read(f, Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadReal(f: Text): real;
|
function ReadReal(f: Text): real;
|
||||||
begin
|
begin
|
||||||
var x: real;
|
Read(f, Result);
|
||||||
read(f, x);
|
|
||||||
Result := x;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadChar(f: Text): char;
|
function ReadChar(f: Text): char;
|
||||||
begin
|
begin
|
||||||
var x: char;
|
Read(f, Result);
|
||||||
read(f, x);
|
|
||||||
Result := x;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadString(f: Text): string;
|
function ReadString(f: Text): string;
|
||||||
begin
|
begin
|
||||||
var x: string;
|
Read(f, Result);
|
||||||
read(f, x);
|
Readln(f);
|
||||||
readln(f);
|
|
||||||
Result := x;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadBoolean(f: Text): boolean;
|
function ReadBoolean(f: Text): boolean;
|
||||||
begin
|
begin
|
||||||
var x: boolean;
|
Read(f, Result);
|
||||||
read(f, x);
|
|
||||||
Result := x;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadlnInteger(f: Text): integer;
|
function ReadlnInteger(f: Text): integer;
|
||||||
begin
|
begin
|
||||||
Result := ReadInteger(f);
|
Result := ReadInteger(f);
|
||||||
readln(f);
|
Readln(f);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ReadlnInt64(f: Text): int64;
|
||||||
|
begin
|
||||||
|
Result := ReadInt64(f);
|
||||||
|
Readln(f);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadlnReal(f: Text): real;
|
function ReadlnReal(f: Text): real;
|
||||||
begin
|
begin
|
||||||
Result := ReadReal(f);
|
Result := ReadReal(f);
|
||||||
readln(f);
|
Readln(f);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadlnChar(f: Text): char;
|
function ReadlnChar(f: Text): char;
|
||||||
begin
|
begin
|
||||||
Result := ReadChar(f);
|
Result := ReadChar(f);
|
||||||
readln(f);
|
Readln(f);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadlnString(f: Text): string;
|
function ReadlnString(f: Text): string;
|
||||||
|
|
@ -5734,7 +5795,7 @@ end;
|
||||||
function ReadlnBoolean(f: Text): boolean;
|
function ReadlnBoolean(f: Text): boolean;
|
||||||
begin
|
begin
|
||||||
Result := ReadBoolean(f);
|
Result := ReadBoolean(f);
|
||||||
readln(f);
|
Readln(f);
|
||||||
end;
|
end;
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
// TextFile methods
|
// TextFile methods
|
||||||
|
|
@ -9347,6 +9408,26 @@ end;
|
||||||
//>> Методы расширения списков # Extension methods for List T
|
//>> Методы расширения списков # Extension methods for List T
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
||||||
|
/// Возвращает последовательность индексов списка
|
||||||
|
function Indices<T>(Self: List<T>): sequence of integer; extensionmethod := Range(0, Self.Count - 1);
|
||||||
|
|
||||||
|
/// Возвращает последовательность индексов элементов списка, удовлетворяющих условию
|
||||||
|
function Indices<T>(Self: List<T>; cond: T->boolean): sequence of integer; extensionmethod;
|
||||||
|
begin
|
||||||
|
for var i := 0 to Self.Count - 1 do
|
||||||
|
if cond(Self[i]) then
|
||||||
|
yield i;
|
||||||
|
end;
|
||||||
|
|
||||||
|
/// Возвращает последовательность индексов элементов списка, удовлетворяющих условию
|
||||||
|
function Indices<T>(Self: List<T>; cond: (T,integer) ->boolean): sequence of integer; extensionmethod;
|
||||||
|
begin
|
||||||
|
for var i := 0 to Self.Count - 1 do
|
||||||
|
if cond(Self[i], i) then
|
||||||
|
yield i;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
/// Перемешивает элементы списка случайным образом
|
/// Перемешивает элементы списка случайным образом
|
||||||
function Shuffle<T>(Self: List<T>): List<T>; extensionmethod;
|
function Shuffle<T>(Self: List<T>): List<T>; extensionmethod;
|
||||||
begin
|
begin
|
||||||
|
|
@ -9725,8 +9806,11 @@ end;
|
||||||
function SystemSliceListImpl<T>(Self: List<T>; situation: integer; from, &to: integer; step: integer := 1): List<T>;
|
function SystemSliceListImpl<T>(Self: List<T>; situation: integer; from, &to: integer; step: integer := 1): List<T>;
|
||||||
begin
|
begin
|
||||||
var count := CheckAndCorrectFromToAndCalcCountForSystemSlice(situation, Self.Count, from, &to, step);
|
var count := CheckAndCorrectFromToAndCalcCountForSystemSlice(situation, Self.Count, from, &to, step);
|
||||||
|
{if (step=1) and (count>32) then // 32 - empirical
|
||||||
Result := CreateSliceFromListInternal(Self, from, step, count);
|
begin
|
||||||
|
Result := Self.GetRange(from,count);
|
||||||
|
end
|
||||||
|
else} Result := CreateSliceFromListInternal(Self, from, step, count);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
///--
|
///--
|
||||||
|
|
@ -10518,8 +10602,12 @@ end;
|
||||||
function SystemSliceArrayImpl<T>(Self: array of T; situation: integer; from, &to: integer; step: integer := 1): array of T;
|
function SystemSliceArrayImpl<T>(Self: array of T; situation: integer; from, &to: integer; step: integer := 1): array of T;
|
||||||
begin
|
begin
|
||||||
var count := CheckAndCorrectFromToAndCalcCountForSystemSlice(situation, Self.Length, from, &to, step);
|
var count := CheckAndCorrectFromToAndCalcCountForSystemSlice(situation, Self.Length, from, &to, step);
|
||||||
|
{if (step = 1) and (count>32) then // 32 - empirical
|
||||||
Result := CreateSliceFromArrayInternal(Self, from, step, count)
|
begin
|
||||||
|
Result := new T[count];
|
||||||
|
System.Array.Copy(Self,from,Result,0,count);
|
||||||
|
end
|
||||||
|
else} Result := CreateSliceFromArrayInternal(Self, from, step, count)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
///--
|
///--
|
||||||
|
|
@ -10582,11 +10670,16 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
///--
|
///--
|
||||||
function InRangeInternal(Self: integer; a,b: integer): boolean; extensionmethod;
|
function InRangeInternal(x: integer; a,b: integer): boolean;
|
||||||
begin
|
begin
|
||||||
Result := (a <= Self) and (Self <= b)
|
Result := (a <= x) and (x <= b)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
///--
|
||||||
|
function InRangeInternal(x: char; a,b: char): boolean;
|
||||||
|
begin
|
||||||
|
Result := (a <= x) and (x <= b)
|
||||||
|
end;
|
||||||
|
|
||||||
// Дополнения февраль 2016: IsEven, IsOdd
|
// Дополнения февраль 2016: IsEven, IsOdd
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,9 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
// SSM 24.12.19 lambda_capture_foreach_counter.pas не проходит если откомментировать эти 2 строки
|
// SSM 24.12.19 lambda_capture_foreach_counter.pas не проходит если откомментировать эти 2 строки
|
||||||
// Причина - лямбда уже начала разбираться
|
// Причина - лямбда уже начала разбираться
|
||||||
// Пробую сделать так: если foreach в лямбде, то оптимизация не делается, а если нет, то делается
|
// Пробую сделать так: если foreach в лямбде, то оптимизация не делается, а если нет, то делается
|
||||||
|
// Пока не получилось - ошибка err0157.pas начинает быть правильной программой
|
||||||
syntax_tree_node p = _foreach_stmt;
|
// Надо как-то переменную x в стек context.loop_var_stack.Push(foreachVariable); помещать !!! Но не сейчас... (SSM 12.01.20)
|
||||||
|
/*syntax_tree_node p = _foreach_stmt;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
p = p.Parent;
|
p = p.Parent;
|
||||||
|
|
@ -27,7 +28,7 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
{
|
{
|
||||||
var feWhat = convert_strong(_foreach_stmt.in_what);
|
var feWhat = convert_strong(_foreach_stmt.in_what);
|
||||||
if (OptimizeForeachInCase1DArray(_foreach_stmt, feWhat)) return;
|
if (OptimizeForeachInCase1DArray(_foreach_stmt, feWhat)) return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
statements_list sl2 = new statements_list(get_location(_foreach_stmt));
|
statements_list sl2 = new statements_list(get_location(_foreach_stmt));
|
||||||
convertion_data_and_alghoritms.statement_list_stack_push(sl2);
|
convertion_data_and_alghoritms.statement_list_stack_push(sl2);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue