иСПРАВЛЕН S.ReadInteger(FROM) - теперь с нуля
function_lambda_definition - добавлено поле для неупакованных параметров \(x,y) Добавлен сахарный визитор - пока для неупакованных параметрво в лямбде - идентификаторов В грамматике добавлены lambda_unpacked_params В StandardSyntaxConverter.cs добавлена UnpackLambdaParametersVisitor.New.ProcessNode(root);
This commit is contained in:
parent
8eadef3cf5
commit
65e7bb188b
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "7";
|
||||
public const string Build = "2";
|
||||
public const string Revision = "2842";
|
||||
public const string Revision = "2852";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%COREVERSION%=2
|
||||
%REVISION%=2842
|
||||
%REVISION%=2852
|
||||
%MINOR%=7
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// This CSharp output file generated by Gardens Point LEX
|
||||
// Version: 1.1.3.301
|
||||
// Machine: DESKTOP-G8V08V4
|
||||
// DateTime: 02.03.2021 16:53:31
|
||||
// DateTime: 06.03.2021 10:59:03
|
||||
// UserName: ?????????
|
||||
// GPLEX input file <ABCPascal.lex>
|
||||
// GPLEX frame file <embedded resource>
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@
|
|||
%type <ex> const_factor const_factor_without_unary_op const_variable_2 const_term const_variable literal_or_number unsigned_number variable_or_literal_or_number
|
||||
%type <stn> program_block
|
||||
%type <ob> optional_var class_attribute class_attributes class_attributes1
|
||||
%type <ob> lambda_unpacked_params lambda_unpacked_params_or_id lambda_list_of_unpacked_params_or_id
|
||||
%type <stn> member_list_section optional_component_list_seq_end
|
||||
%type <stn> const_decl only_const_decl
|
||||
%type <stn> const_decl_sect
|
||||
|
|
@ -4723,6 +4724,40 @@ assign_operator
|
|||
{ $$ = $1; }
|
||||
;
|
||||
|
||||
lambda_unpacked_params
|
||||
: tkBackSlashRoundOpen lambda_list_of_unpacked_params_or_id tkComma lambda_unpacked_params_or_id tkRoundClose
|
||||
{
|
||||
// ðåçóëüòàò íàäî ïðèñâîèòü êàêîìó òî ñàõàðíîìó ïîëþ â function_lambda_definition
|
||||
$$ = $2;
|
||||
($$ as List<ident_or_list>).Add($4 as ident_or_list);
|
||||
}
|
||||
;
|
||||
|
||||
lambda_unpacked_params_or_id
|
||||
: lambda_unpacked_params
|
||||
{
|
||||
$$ = new List<ident_or_list>($1 as List<ident_or_list>);
|
||||
}
|
||||
| identifier
|
||||
{
|
||||
$$ = new ident_or_list($1 as ident);
|
||||
}
|
||||
;
|
||||
|
||||
lambda_list_of_unpacked_params_or_id
|
||||
: lambda_unpacked_params_or_id
|
||||
{
|
||||
$$ = new List<ident_or_list>();
|
||||
($$ as List<ident_or_list>).Add($1 as ident_or_list);
|
||||
}
|
||||
| lambda_list_of_unpacked_params_or_id tkComma lambda_unpacked_params_or_id
|
||||
{
|
||||
$$ = $1;
|
||||
($$ as List<ident_or_list>).Add($3 as ident_or_list);
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
func_decl_lambda
|
||||
: identifier tkArrow lambda_function_body
|
||||
{
|
||||
|
|
@ -4841,8 +4876,12 @@ func_decl_lambda
|
|||
else $$ = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, null, pair.exprs, @$);
|
||||
}
|
||||
}
|
||||
| tkBackSlashRoundOpen ident tkComma ident_list tkRoundClose rem_lambda // ëÿìáäà ñ ðàñïàêîâêîé
|
||||
| lambda_unpacked_params rem_lambda // ëÿìáäà ñ ðàñïàêîâêîé
|
||||
{
|
||||
var pair = $2 as pair_type_stlist;
|
||||
$$ = new function_lambda_definition(lambdaHelper.CreateLambdaName(), null,
|
||||
new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), @1), pair.exprs, @$);
|
||||
($$ as function_lambda_definition).unpacked_params = $1 as List<ident_or_list>;
|
||||
}
|
||||
| expl_func_decl_lambda
|
||||
{
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -318,6 +318,5 @@
|
|||
<name value="var_decl_part" />
|
||||
<name value="typed_const" />
|
||||
<name value="var_stmt" />
|
||||
<name value="func_decl_lambda" />
|
||||
</tag>
|
||||
</tags>
|
||||
|
|
@ -318,6 +318,8 @@ script=
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
3.7.2.2842
|
||||
3.7.2.2852
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.7.2.2842'
|
||||
!define VERSION '3.7.2.2852'
|
||||
|
|
|
|||
|
|
@ -1434,6 +1434,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
{
|
||||
public object RealSemTypeOfResExpr = null; // Result := ex; - семантический тип ex - нужно для лучшего выбора среди перегруженных методов с параметрами-лямбдами
|
||||
public object RealSemTypeOfResult = null;
|
||||
public List<ident_or_list> unpacked_params = null; // SSM 04/03/21 - сахарный узел, содержащий параметры, которые необходимо распаковать: (\(x,y,z),\(a,b)))
|
||||
|
||||
public function_lambda_definition(string name, formal_parameters formalPars, type_definition returnType, statement_list body, int usedkw, SourceContext sc)
|
||||
{
|
||||
|
|
@ -2032,4 +2033,19 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
public object ext = null;
|
||||
}
|
||||
|
||||
public class ident_or_list // Это для распаковки параметров в лямбдах \(x,y)
|
||||
{
|
||||
// только одно поле - ненулевое!
|
||||
public ident id;
|
||||
public List<ident_or_list> lst;
|
||||
public ident_or_list(ident id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
public ident_or_list(List<ident_or_list> lst)
|
||||
{
|
||||
this.lst = lst;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ namespace PascalABCCompiler.SyntaxTreeConverters
|
|||
// new range - до всего! До выноса выражения с лямбдой из foreach. 11.07 добавил поиск yields и присваивание pd.HasYield
|
||||
NewRangeDesugarAndFindHasYieldVisitor.New.ProcessNode(root);
|
||||
|
||||
// Распаковка параметров в лямбдах
|
||||
UnpackLambdaParametersVisitor.New.ProcessNode(root);
|
||||
|
||||
// Unnamed Records перенёс сюда
|
||||
UnnamedRecordsCheckVisitor.New.ProcessNode(root);
|
||||
|
||||
|
|
@ -47,7 +50,6 @@ namespace PascalABCCompiler.SyntaxTreeConverters
|
|||
// tuple_node
|
||||
TupleVisitor.New.ProcessNode(root);
|
||||
|
||||
|
||||
// index
|
||||
IndexVisitor.New.ProcessNode(root);
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
<Compile Include="AllVarsInProcYieldsProba.cs" />
|
||||
<Compile Include="BaseVisitors\CollectNamespaces.cs" />
|
||||
<Compile Include="BaseVisitors\HasStatementVisitor.cs" />
|
||||
<Compile Include="SugarVisitors\UnpackLambdaParametersVisitor.cs" />
|
||||
<Compile Include="UniversalVisitors\ABCStatisticsVisitors.cs" />
|
||||
<Compile Include="BaseVisitors\SmallHelperVisitors.cs" />
|
||||
<Compile Include="ChangeWhileVisitor.cs" />
|
||||
|
|
|
|||
|
|
@ -12663,19 +12663,25 @@ end;
|
|||
/// Считывает целое из строки начиная с позиции from и устанавливает from за считанным значением
|
||||
function ReadInteger(Self: string; var from: integer): integer; extensionmethod;
|
||||
begin
|
||||
Result := ReadIntegerFromString(Self, from);
|
||||
var from1 := from + 1;
|
||||
Result := ReadIntegerFromString(Self, from1);
|
||||
from := from1 - 1;
|
||||
end;
|
||||
|
||||
/// Считывает вещественное из строки начиная с позиции from и устанавливает from за считанным значением
|
||||
function ReadReal(Self: string; var from: integer): real; extensionmethod;
|
||||
begin
|
||||
Result := ReadRealFromString(Self, from);
|
||||
var from1 := from + 1;
|
||||
Result := ReadRealFromString(Self, from1);
|
||||
from := from1 - 1;
|
||||
end;
|
||||
|
||||
/// Считывает слово из строки начиная с позиции from и устанавливает from за считанным значением
|
||||
function ReadWord(Self: string; var from: integer): string; extensionmethod;
|
||||
begin
|
||||
Result := ReadwordFromString(Self, from);
|
||||
var from1 := from + 1;
|
||||
Result := ReadwordFromString(Self, from1);
|
||||
from := from1 - 1;
|
||||
end;
|
||||
|
||||
/// Преобразует строку в целое
|
||||
|
|
|
|||
|
|
@ -118,5 +118,15 @@ namespace TreeConverter.LambdaExpressions
|
|||
public override void visit(function_lambda_definition funcLamDef)
|
||||
{
|
||||
}
|
||||
|
||||
public override void visit(semantic_check_sugared_statement_node st)
|
||||
{
|
||||
if (st.typ as System.Type == typeof(assign_var_tuple))
|
||||
{
|
||||
var idents = st.lst[0] as ident_list;
|
||||
var expr = st.lst[1] as expression;
|
||||
syntaxTreeVisitor.semantic_check_assign_var_tuple(idents, expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12663,19 +12663,25 @@ end;
|
|||
/// Считывает целое из строки начиная с позиции from и устанавливает from за считанным значением
|
||||
function ReadInteger(Self: string; var from: integer): integer; extensionmethod;
|
||||
begin
|
||||
Result := ReadIntegerFromString(Self, from);
|
||||
var from1 := from + 1;
|
||||
Result := ReadIntegerFromString(Self, from1);
|
||||
from := from1 - 1;
|
||||
end;
|
||||
|
||||
/// Считывает вещественное из строки начиная с позиции from и устанавливает from за считанным значением
|
||||
function ReadReal(Self: string; var from: integer): real; extensionmethod;
|
||||
begin
|
||||
Result := ReadRealFromString(Self, from);
|
||||
var from1 := from + 1;
|
||||
Result := ReadRealFromString(Self, from1);
|
||||
from := from1 - 1;
|
||||
end;
|
||||
|
||||
/// Считывает слово из строки начиная с позиции from и устанавливает from за считанным значением
|
||||
function ReadWord(Self: string; var from: integer): string; extensionmethod;
|
||||
begin
|
||||
Result := ReadwordFromString(Self, from);
|
||||
var from1 := from + 1;
|
||||
Result := ReadwordFromString(Self, from1);
|
||||
from := from1 - 1;
|
||||
end;
|
||||
|
||||
/// Преобразует строку в целое
|
||||
|
|
|
|||
Loading…
Reference in a new issue