Ликвидация зависимости проектов PascalABCSaushkinParser и SyntaxVisitors от
проекта TreeConverter, то есть, от семантического уровня Необходимо применить эти изменения и перекомпилировать в ОС РОСА
This commit is contained in:
parent
232f3a2238
commit
af9b6acb91
|
|
@ -117,6 +117,10 @@
|
|||
<Project>{44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}</Project>
|
||||
<Name>Errors</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\LambdaAnySynToSemConverter\LambdaAnySynToSemConverter.csproj">
|
||||
<Project>{27d9800e-2689-4aa1-a2d6-128e4a9bae98}</Project>
|
||||
<Name>LambdaAnySynToSemConverter</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Localization\Localization.csproj">
|
||||
<Project>{2DE2842F-0912-4251-BC0F-480854C44A13}</Project>
|
||||
<Name>Localization</Name>
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ namespace PascalABCCompiler.SyntaxTreeConverters
|
|||
{
|
||||
var st = new StandardSyntaxTreeConverter();
|
||||
syntaxTreeConverters.Add(st);
|
||||
var lam = new SyntaxSemanticVisitors.LambdaAnyConverter(); // синтактико семантический конвертер
|
||||
syntaxTreeConverters.Add(lam);
|
||||
}
|
||||
public void AddConverters()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "9";
|
||||
public const string Build = "0";
|
||||
public const string Revision = "3293";
|
||||
public const string Revision = "3295";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%MINOR%=9
|
||||
%REVISION%=3293
|
||||
%REVISION%=3295
|
||||
%COREVERSION%=0
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
41
LambdaAnySynToSemConverter/LambdaAnyConverter.cs
Normal file
41
LambdaAnySynToSemConverter/LambdaAnyConverter.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using PascalABCCompiler.SyntaxTree;
|
||||
using PascalABCCompiler.TreeRealization;
|
||||
using PascalABCCompiler.SyntaxTreeConverters;
|
||||
|
||||
/// <summary>
|
||||
/// Этот визитор позволяет при переходе к семантике заменить синтаксический узел lambda_any_type_node_syntax
|
||||
/// на семантический lambda_any_type_node
|
||||
/// Это - единственное место, которое делало зависимость синтаксиса от семантики и этот визитор ее убирает
|
||||
/// Мы вызываем этот визитор в компиляторе сразу после всех синтаксических визиторов
|
||||
/// </summary>
|
||||
namespace SyntaxSemanticVisitors
|
||||
{
|
||||
public class LambdaAnyConverter : ISyntaxTreeConverter
|
||||
{
|
||||
public string Name { get; } = "LambdaAny";
|
||||
public syntax_tree_node Convert(syntax_tree_node root)
|
||||
{
|
||||
LambdaAnyVisitor.New.ProcessNode(root);
|
||||
return root;
|
||||
}
|
||||
}
|
||||
|
||||
public class LambdaAnyVisitor : BaseChangeVisitor
|
||||
{
|
||||
public static LambdaAnyVisitor New
|
||||
{
|
||||
get { return new LambdaAnyVisitor(); }
|
||||
}
|
||||
public override void visit(lambda_inferred_type lit)
|
||||
{
|
||||
if (lit.real_type is lambda_any_type_node_syntax)
|
||||
lit.real_type = new lambda_any_type_node(); // семантический
|
||||
}
|
||||
}
|
||||
}
|
||||
67
LambdaAnySynToSemConverter/LambdaAnySynToSemConverter.csproj
Normal file
67
LambdaAnySynToSemConverter/LambdaAnySynToSemConverter.csproj
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>LambdaAnySynToSemConverter</RootNamespace>
|
||||
<AssemblyName>LambdaAnySynToSemConverter</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="LambdaAnyConverter.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SyntaxTreeConverters\SyntaxTreeConverters.csproj">
|
||||
<Project>{f10a5330-dcf4-4533-877c-7b1b1be23884}</Project>
|
||||
<Name>SyntaxTreeConverters</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\SyntaxTree\SyntaxTree.csproj">
|
||||
<Project>{c2cac65a-b2ae-4ccc-b067-e6b8e75df73a}</Project>
|
||||
<Name>SyntaxTree</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\SyntaxVisitors\SyntaxVisitors.csproj">
|
||||
<Project>{a9ab4282-83b4-41a7-86c3-e5bf6a45e7e2}</Project>
|
||||
<Name>SyntaxVisitors</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\TreeConverter\TreeConverter.csproj">
|
||||
<Project>{1c9c945a-586d-42a2-a06b-65d84fa7ff78}</Project>
|
||||
<Name>TreeConverter</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
36
LambdaAnySynToSemConverter/Properties/AssemblyInfo.cs
Normal file
36
LambdaAnySynToSemConverter/Properties/AssemblyInfo.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Общие сведения об этой сборке предоставляются следующим набором
|
||||
// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
|
||||
// связанные со сборкой.
|
||||
[assembly: AssemblyTitle("LambdaAnyTypeNodeSyntaxToSemanticConverter")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("LambdaAnyTypeNodeSyntaxToSemanticConverter")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
|
||||
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
|
||||
// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
|
||||
[assembly: Guid("27d9800e-2689-4aa1-a2d6-128e4a9bae98")]
|
||||
|
||||
// Сведения о версии сборки состоят из следующих четырех значений:
|
||||
//
|
||||
// Основной номер версии
|
||||
// Дополнительный номер версии
|
||||
// Номер сборки
|
||||
// Редакция
|
||||
//
|
||||
// Можно задать все значения или принять номер сборки и номер редакции по умолчанию.
|
||||
// используя "*", как показано ниже:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Binary file not shown.
|
|
@ -2,7 +2,7 @@
|
|||
// This CSharp output file generated by Gardens Point LEX
|
||||
// Version: 1.1.3.301
|
||||
// Machine: DESKTOP-G8V08V4
|
||||
// DateTime: 08.05.2023 10:16:52
|
||||
// DateTime: 31.05.2023 10:03:11
|
||||
// UserName: ?????????
|
||||
// GPLEX input file <ABCPascal.lex>
|
||||
// GPLEX frame file <embedded resource>
|
||||
|
|
|
|||
|
|
@ -2286,8 +2286,8 @@ typed_var_init_expression
|
|||
| identifier tkArrow lambda_function_body
|
||||
{
|
||||
var idList = new ident_list($1, @1);
|
||||
var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), @1), parametr_kind.none, null, @1), @1);
|
||||
$$ = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), @1), $3 as statement_list, @$);
|
||||
var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new lambda_any_type_node_syntax(), @1), parametr_kind.none, null, @1), @1);
|
||||
$$ = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, new lambda_inferred_type(new lambda_any_type_node_syntax(), @1), $3 as statement_list, @$);
|
||||
}
|
||||
| tkRoundOpen tkRoundClose lambda_type_ref tkArrow lambda_function_body
|
||||
{
|
||||
|
|
@ -2308,7 +2308,7 @@ typed_var_init_expression
|
|||
idList.idents.Add(el.expressions[j] as ident);
|
||||
}
|
||||
|
||||
var any = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), @2);
|
||||
var any = new lambda_inferred_type(new lambda_any_type_node_syntax(), @2);
|
||||
|
||||
var formalPars = new formal_parameters(new typed_parameters(idList, any, parametr_kind.none, null, @2), @2);
|
||||
$$ = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, any, $5 as statement_list, @$);
|
||||
|
|
@ -4895,10 +4895,10 @@ func_decl_lambda
|
|||
: identifier tkArrow lambda_function_body
|
||||
{
|
||||
var idList = new ident_list($1, @1);
|
||||
var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), @1), parametr_kind.none, null, @1), @1);
|
||||
var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new lambda_any_type_node_syntax(), @1), parametr_kind.none, null, @1), @1);
|
||||
//var sl = $3 as statement_list;
|
||||
//if (sl.expr_lambda_body || SyntaxVisitors.HasNameVisitor.HasName($3, "Result") != null) // åñëè ýòî áûëî âûðàæåíèå èëè åñòü ïåðåìåííàÿ Result, òî àâòîâûâîä òèïà
|
||||
$$ = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), @1), $3 as statement_list, @$);
|
||||
$$ = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, new lambda_inferred_type(new lambda_any_type_node_syntax(), @1), $3 as statement_list, @$);
|
||||
//else
|
||||
//$$ = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, null, $3 as statement_list, @$);
|
||||
}
|
||||
|
|
@ -4923,7 +4923,7 @@ func_decl_lambda
|
|||
| tkRoundOpen identifier tkSemiColon full_lambda_fp_list tkRoundClose lambda_type_ref_noproctype tkArrow lambda_function_body
|
||||
{
|
||||
var idList = new ident_list($2, @2);
|
||||
var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null), parametr_kind.none, null, @2), LexLocation.MergeAll(@2,@3,@4));
|
||||
var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new lambda_any_type_node_syntax(), null), parametr_kind.none, null, @2), LexLocation.MergeAll(@2,@3,@4));
|
||||
for (int i = 0; i < ($4 as formal_parameters).Count; i++)
|
||||
formalPars.Add(($4 as formal_parameters).params_list[i]);
|
||||
var sl = $8 as statement_list;
|
||||
|
|
@ -4978,7 +4978,7 @@ func_decl_lambda
|
|||
lst_ex.Add(x);
|
||||
|
||||
function_lambda_definition fld = null; //= new function_lambda_definition(lambdaHelper.CreateLambdaName(), null,
|
||||
//new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), @2), pair.exprs, @$);
|
||||
//new lambda_inferred_type(new lambda_any_type_node_syntax(), @2), pair.exprs, @$);
|
||||
|
||||
var sl1 = pair.exprs;
|
||||
if (sl1.expr_lambda_body || SyntaxVisitors.HasNameVisitor.HasName(sl1, "result") != null) // òî íàäî âûâîäèòü
|
||||
|
|
@ -4994,7 +4994,7 @@ func_decl_lambda
|
|||
var idd = $2 as ident;
|
||||
if (idd==null)
|
||||
parsertools.AddErrorFromResource("ONE_TKIDENTIFIER",@2);
|
||||
var lambda_inf_type = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null);
|
||||
var lambda_inf_type = new lambda_inferred_type(new lambda_any_type_node_syntax(), null);
|
||||
var new_typed_pars = new typed_parameters(new ident_list(idd, idd.source_context), lambda_inf_type, parametr_kind.none, null, idd.source_context);
|
||||
formal_pars.Add(new_typed_pars);
|
||||
foreach (var id in ($4 as expression_list).expressions)
|
||||
|
|
@ -5003,7 +5003,7 @@ func_decl_lambda
|
|||
if (idd1==null)
|
||||
parsertools.AddErrorFromResource("ONE_TKIDENTIFIER",id.source_context);
|
||||
|
||||
lambda_inf_type = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null);
|
||||
lambda_inf_type = new lambda_inferred_type(new lambda_any_type_node_syntax(), null);
|
||||
new_typed_pars = new typed_parameters(new ident_list(idd1, idd1.source_context), lambda_inf_type, parametr_kind.none, null, idd1.source_context);
|
||||
formal_pars.Add(new_typed_pars);
|
||||
}
|
||||
|
|
@ -5055,7 +5055,7 @@ func_decl_lambda
|
|||
var pair = $2 as pair_type_stlist;
|
||||
// ïîêà ôîðìàëüíûå ïàðàìåòðû - null. Ðàñêðîåì èõ ñàõàðíûì âèçèòîðîì
|
||||
$$ = new function_lambda_definition(lambdaHelper.CreateLambdaName(), null,
|
||||
new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), @1), pair.exprs, @$);
|
||||
new lambda_inferred_type(new lambda_any_type_node_syntax(), @1), pair.exprs, @$);
|
||||
// unpacked_params - ýòî äëÿ îäíîãî ïàðàìåòðà. Äëÿ íåñêîëüêèõ - íàäî äðóãóþ ñòðóêòóðó. Âîçìîæíî, ñïèñîê ñïèñêîâ
|
||||
var lst_ex = new List<expression>();
|
||||
lst_ex.Add($1 as unpacked_list_of_ident_or_list);
|
||||
|
|
@ -5118,7 +5118,7 @@ full_lambda_fp_list
|
|||
$$ = new formal_parameters();
|
||||
foreach (var id in typed_pars.idents.idents)
|
||||
{
|
||||
var lambda_inf_type = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null);
|
||||
var lambda_inf_type = new lambda_inferred_type(new lambda_any_type_node_syntax(), null);
|
||||
var new_typed_pars = new typed_parameters(new ident_list(id, id.source_context), lambda_inf_type, parametr_kind.none, null, id.source_context);
|
||||
($$ as formal_parameters).Add(new_typed_pars);
|
||||
}
|
||||
|
|
@ -5145,7 +5145,7 @@ lambda_simple_fp_sect
|
|||
lambda_type_ref
|
||||
:
|
||||
{
|
||||
$$ = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null);
|
||||
$$ = new lambda_inferred_type(new lambda_any_type_node_syntax(), null);
|
||||
}
|
||||
| tkColon fptype
|
||||
{
|
||||
|
|
@ -5156,7 +5156,7 @@ lambda_type_ref
|
|||
lambda_type_ref_noproctype
|
||||
:
|
||||
{
|
||||
$$ = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null);
|
||||
$$ = new lambda_inferred_type(new lambda_any_type_node_syntax(), null);
|
||||
}
|
||||
| tkColon fptype_noproctype
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
// GPPG version 1.3.6
|
||||
// Machine: DESKTOP-G8V08V4
|
||||
// DateTime: 08.05.2023 10:16:52
|
||||
// DateTime: 31.05.2023 10:03:12
|
||||
// UserName: ?????????
|
||||
// Input file <D:\PABC_Git\Parsers\PascalABCParserNewSaushkin\ABCPascal.y>
|
||||
// Input file <ABCPascal.y>
|
||||
|
||||
// options: no-lines gplex
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ public abstract class ScanBase : AbstractScanner<PascalABCSavParser.Union,LexLoc
|
|||
|
||||
public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, LexLocation>
|
||||
{
|
||||
// Verbatim content from D:\PABC_Git\Parsers\PascalABCParserNewSaushkin\ABCPascal.y
|
||||
// Verbatim content from ABCPascal.y
|
||||
// <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> GPPGParser, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> gppg
|
||||
public syntax_tree_node root; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
public ParserLambdaHelper lambdaHelper = new ParserLambdaHelper();
|
||||
|
||||
public GPPGParser(AbstractScanner<PascalABCSavParser.Union, LexLocation> scanner) : base(scanner) { }
|
||||
// End verbatim content from D:\PABC_Git\Parsers\PascalABCParserNewSaushkin\ABCPascal.y
|
||||
// End verbatim content from ABCPascal.y
|
||||
|
||||
#pragma warning disable 649
|
||||
private static Dictionary<int, string> aliasses;
|
||||
|
|
@ -4823,8 +4823,8 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
case 410: // typed_var_init_expression -> identifier, tkArrow, lambda_function_body
|
||||
{
|
||||
var idList = new ident_list(ValueStack[ValueStack.Depth-3].id, LocationStack[LocationStack.Depth-3]);
|
||||
var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), LocationStack[LocationStack.Depth-3]), parametr_kind.none, null, LocationStack[LocationStack.Depth-3]), LocationStack[LocationStack.Depth-3]);
|
||||
CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), LocationStack[LocationStack.Depth-3]), ValueStack[ValueStack.Depth-1].stn as statement_list, CurrentLocationSpan);
|
||||
var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new lambda_any_type_node_syntax(), LocationStack[LocationStack.Depth-3]), parametr_kind.none, null, LocationStack[LocationStack.Depth-3]), LocationStack[LocationStack.Depth-3]);
|
||||
CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, new lambda_inferred_type(new lambda_any_type_node_syntax(), LocationStack[LocationStack.Depth-3]), ValueStack[ValueStack.Depth-1].stn as statement_list, CurrentLocationSpan);
|
||||
}
|
||||
break;
|
||||
case 411: // typed_var_init_expression -> tkRoundOpen, tkRoundClose, lambda_type_ref,
|
||||
|
|
@ -4849,7 +4849,7 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
idList.idents.Add(el.expressions[j] as ident);
|
||||
}
|
||||
|
||||
var any = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), LocationStack[LocationStack.Depth-4]);
|
||||
var any = new lambda_inferred_type(new lambda_any_type_node_syntax(), LocationStack[LocationStack.Depth-4]);
|
||||
|
||||
var formalPars = new formal_parameters(new typed_parameters(idList, any, parametr_kind.none, null, LocationStack[LocationStack.Depth-4]), LocationStack[LocationStack.Depth-4]);
|
||||
CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, any, ValueStack[ValueStack.Depth-1].stn as statement_list, CurrentLocationSpan);
|
||||
|
|
@ -6729,9 +6729,6 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
if (ValueStack[ValueStack.Depth-4].ex is index)
|
||||
parsertools.AddErrorFromResource("UNEXPECTED_SYMBOL{0}", LocationStack[LocationStack.Depth-4], "^");
|
||||
CurrentSemanticValue.ex = new method_call(ValueStack[ValueStack.Depth-4].ex as addressed_value,ValueStack[ValueStack.Depth-2].stn as expression_list, CurrentLocationSpan);
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
}
|
||||
break;
|
||||
case 786: // variable -> identifier
|
||||
|
|
@ -7467,10 +7464,10 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
case 978: // func_decl_lambda -> identifier, tkArrow, lambda_function_body
|
||||
{
|
||||
var idList = new ident_list(ValueStack[ValueStack.Depth-3].id, LocationStack[LocationStack.Depth-3]);
|
||||
var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), LocationStack[LocationStack.Depth-3]), parametr_kind.none, null, LocationStack[LocationStack.Depth-3]), LocationStack[LocationStack.Depth-3]);
|
||||
var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new lambda_any_type_node_syntax(), LocationStack[LocationStack.Depth-3]), parametr_kind.none, null, LocationStack[LocationStack.Depth-3]), LocationStack[LocationStack.Depth-3]);
|
||||
//var sl = $3 as statement_list;
|
||||
//if (sl.expr_lambda_body || SyntaxVisitors.HasNameVisitor.HasName($3, "Result") != null) // <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Result, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), LocationStack[LocationStack.Depth-3]), ValueStack[ValueStack.Depth-1].stn as statement_list, CurrentLocationSpan);
|
||||
CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, new lambda_inferred_type(new lambda_any_type_node_syntax(), LocationStack[LocationStack.Depth-3]), ValueStack[ValueStack.Depth-1].stn as statement_list, CurrentLocationSpan);
|
||||
//else
|
||||
//$$ = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, null, $3 as statement_list, @$);
|
||||
}
|
||||
|
|
@ -7502,7 +7499,7 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
// lambda_function_body
|
||||
{
|
||||
var idList = new ident_list(ValueStack[ValueStack.Depth-7].id, LocationStack[LocationStack.Depth-7]);
|
||||
var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null), parametr_kind.none, null, LocationStack[LocationStack.Depth-7]), LexLocation.MergeAll(LocationStack[LocationStack.Depth-7],LocationStack[LocationStack.Depth-6],LocationStack[LocationStack.Depth-5]));
|
||||
var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new lambda_any_type_node_syntax(), null), parametr_kind.none, null, LocationStack[LocationStack.Depth-7]), LexLocation.MergeAll(LocationStack[LocationStack.Depth-7],LocationStack[LocationStack.Depth-6],LocationStack[LocationStack.Depth-5]));
|
||||
for (int i = 0; i < (ValueStack[ValueStack.Depth-5].stn as formal_parameters).Count; i++)
|
||||
formalPars.Add((ValueStack[ValueStack.Depth-5].stn as formal_parameters).params_list[i]);
|
||||
var sl = ValueStack[ValueStack.Depth-1].stn as statement_list;
|
||||
|
|
@ -7563,7 +7560,7 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
lst_ex.Add(x);
|
||||
|
||||
function_lambda_definition fld = null; //= new function_lambda_definition(lambdaHelper.CreateLambdaName(), null,
|
||||
//new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), @2), pair.exprs, @$);
|
||||
//new lambda_inferred_type(new lambda_any_type_node_syntax(), @2), pair.exprs, @$);
|
||||
|
||||
var sl1 = pair.exprs;
|
||||
if (sl1.expr_lambda_body || SyntaxVisitors.HasNameVisitor.HasName(sl1, "result") != null) // <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
|
@ -7579,7 +7576,7 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
var idd = ValueStack[ValueStack.Depth-7].ex as ident;
|
||||
if (idd==null)
|
||||
parsertools.AddErrorFromResource("ONE_TKIDENTIFIER",LocationStack[LocationStack.Depth-7]);
|
||||
var lambda_inf_type = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null);
|
||||
var lambda_inf_type = new lambda_inferred_type(new lambda_any_type_node_syntax(), null);
|
||||
var new_typed_pars = new typed_parameters(new ident_list(idd, idd.source_context), lambda_inf_type, parametr_kind.none, null, idd.source_context);
|
||||
formal_pars.Add(new_typed_pars);
|
||||
foreach (var id in (ValueStack[ValueStack.Depth-5].stn as expression_list).expressions)
|
||||
|
|
@ -7588,7 +7585,7 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
if (idd1==null)
|
||||
parsertools.AddErrorFromResource("ONE_TKIDENTIFIER",id.source_context);
|
||||
|
||||
lambda_inf_type = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null);
|
||||
lambda_inf_type = new lambda_inferred_type(new lambda_any_type_node_syntax(), null);
|
||||
new_typed_pars = new typed_parameters(new ident_list(idd1, idd1.source_context), lambda_inf_type, parametr_kind.none, null, idd1.source_context);
|
||||
formal_pars.Add(new_typed_pars);
|
||||
}
|
||||
|
|
@ -7641,7 +7638,7 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
var pair = ValueStack[ValueStack.Depth-1].ob as pair_type_stlist;
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - null. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), null,
|
||||
new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), LocationStack[LocationStack.Depth-2]), pair.exprs, CurrentLocationSpan);
|
||||
new lambda_inferred_type(new lambda_any_type_node_syntax(), LocationStack[LocationStack.Depth-2]), pair.exprs, CurrentLocationSpan);
|
||||
// unpacked_params - <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
var lst_ex = new List<expression>();
|
||||
lst_ex.Add(ValueStack[ValueStack.Depth-2].ex as unpacked_list_of_ident_or_list);
|
||||
|
|
@ -7711,7 +7708,7 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
CurrentSemanticValue.stn = new formal_parameters();
|
||||
foreach (var id in typed_pars.idents.idents)
|
||||
{
|
||||
var lambda_inf_type = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null);
|
||||
var lambda_inf_type = new lambda_inferred_type(new lambda_any_type_node_syntax(), null);
|
||||
var new_typed_pars = new typed_parameters(new ident_list(id, id.source_context), lambda_inf_type, parametr_kind.none, null, id.source_context);
|
||||
(CurrentSemanticValue.stn as formal_parameters).Add(new_typed_pars);
|
||||
}
|
||||
|
|
@ -7735,7 +7732,7 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
break;
|
||||
case 998: // lambda_type_ref -> /* empty */
|
||||
{
|
||||
CurrentSemanticValue.td = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null);
|
||||
CurrentSemanticValue.td = new lambda_inferred_type(new lambda_any_type_node_syntax(), null);
|
||||
}
|
||||
break;
|
||||
case 999: // lambda_type_ref -> tkColon, fptype
|
||||
|
|
@ -7745,7 +7742,7 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
break;
|
||||
case 1000: // lambda_type_ref_noproctype -> /* empty */
|
||||
{
|
||||
CurrentSemanticValue.td = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null);
|
||||
CurrentSemanticValue.td = new lambda_inferred_type(new lambda_any_type_node_syntax(), null);
|
||||
}
|
||||
break;
|
||||
case 1001: // lambda_type_ref_noproctype -> tkColon, fptype_noproctype
|
||||
|
|
|
|||
|
|
@ -365,5 +365,6 @@ script=
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -135,10 +135,6 @@
|
|||
<Project>{a9ab4282-83b4-41a7-86c3-e5bf6a45e7e2}</Project>
|
||||
<Name>SyntaxVisitors</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\TreeConverter\TreeConverter.csproj">
|
||||
<Project>{1c9c945a-586d-42a2-a06b-65d84fa7ff78}</Project>
|
||||
<Name>TreeConverter</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
|||
|
|
@ -105,6 +105,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsSupportLinux", "Plug
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeacherControlPlugin", "VisualPlugins\TraningControlPlugin\TeacherControlPlugin.csproj", "{536CC813-7C4E-42BC-AE3A-BA1427F38756}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LambdaAnySynToSemConverter", "LambdaAnySynToSemConverter\LambdaAnySynToSemConverter.csproj", "{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -487,6 +489,18 @@ Global
|
|||
{536CC813-7C4E-42BC-AE3A-BA1427F38756}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{536CC813-7C4E-42BC-AE3A-BA1427F38756}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{536CC813-7C4E-42BC-AE3A-BA1427F38756}.Release|x86.Build.0 = Release|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -531,6 +545,7 @@ Global
|
|||
{3BF3CEB4-0E08-485A-8E6D-924841818B01} = {26843C5D-9D7E-4C2C-AC14-2D227FA5592E}
|
||||
{E009E776-9280-4061-B5CA-7F0C3E2D3C2A} = {26843C5D-9D7E-4C2C-AC14-2D227FA5592E}
|
||||
{536CC813-7C4E-42BC-AE3A-BA1427F38756} = {EC68A3D8-6D63-4A79-ABA6-BF8E9D7756D7}
|
||||
{27D9800E-2689-4AA1-A2D6-128E4A9BAE98} = {F8CE2712-826B-450B-A72F-D32D80C99858}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {68E993E6-EE86-4DDF-B0A1-4FE884F8AC39}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
3.9.0.3293
|
||||
3.9.0.3295
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.9.0.3293'
|
||||
!define VERSION '3.9.0.3295'
|
||||
|
|
|
|||
|
|
@ -5,6 +5,351 @@ using System.Text;
|
|||
|
||||
namespace PascalABCCompiler.SyntaxTree
|
||||
{
|
||||
#region Генерация новых узлов синтаксического дерева
|
||||
/// <summary>
|
||||
/// Класс для генерации новых узлов синтаксического дерева
|
||||
/// </summary>
|
||||
public class SyntaxTreeNodesConstructor
|
||||
{
|
||||
public static var_statement CreateVarStatementNode(string idName, type_definition varType, expression initValue)
|
||||
{
|
||||
var id = new ident(idName);
|
||||
var idlist = new ident_list(id);
|
||||
var vdef = new var_def_statement(idlist, varType, initValue, definition_attribute.None, false, null);
|
||||
return new var_statement(vdef, null);
|
||||
}
|
||||
|
||||
public static var_statement CreateVarStatementNode(string idName, string varTypeName, expression initValue)
|
||||
{
|
||||
var id = new ident(idName);
|
||||
var idlist = new ident_list(id);
|
||||
var varType = new named_type_reference(varTypeName, null);
|
||||
var vdef = new var_def_statement(idlist, varType, initValue, definition_attribute.None, false, null);
|
||||
return new var_statement(vdef, null);
|
||||
}
|
||||
|
||||
public static var_statement CreateVarStatementNode(ident_list idlist, type_definition varType, expression initValue)
|
||||
{
|
||||
var vdef = new var_def_statement(idlist, varType, initValue, definition_attribute.None, false, null);
|
||||
return new var_statement(vdef, null);
|
||||
}
|
||||
|
||||
public static procedure_definition CreateProcedureDefinitionNode(method_name methName, formal_parameters formalPars, bool ofObject, bool classKeyword, statement procBody, SourceContext sc)
|
||||
{
|
||||
procedure_definition procDef = new procedure_definition();
|
||||
|
||||
procedure_header procHeader = new procedure_header();
|
||||
procHeader.name = methName;
|
||||
procHeader.source_context = sc;
|
||||
if (procHeader.name.meth_name is template_type_name)
|
||||
{
|
||||
procHeader.template_args = (procHeader.name.meth_name as template_type_name).template_args;
|
||||
ident id = new ident(procHeader.name.meth_name.name);
|
||||
procHeader.name.meth_name = id;
|
||||
}
|
||||
procHeader.parameters = formalPars;
|
||||
procHeader.of_object = ofObject;
|
||||
procHeader.class_keyword = classKeyword;
|
||||
|
||||
statement_list stmtList = new statement_list();
|
||||
stmtList.subnodes.Add(procBody);
|
||||
|
||||
block bl = new block(null, null);
|
||||
bl.program_code = stmtList;
|
||||
|
||||
procDef.proc_header = procHeader;
|
||||
procDef.proc_body = (proc_block)bl;
|
||||
|
||||
return procDef;
|
||||
}
|
||||
|
||||
public static procedure_definition CreateFunctionDefinitionNode(method_name methName, formal_parameters formalPars, bool ofObject, bool classKeyword, statement procBody, type_definition returnType, SourceContext sc)
|
||||
{
|
||||
procedure_definition procDef = new procedure_definition();
|
||||
|
||||
function_header procHeader = new function_header();
|
||||
procHeader.name = methName;
|
||||
procHeader.source_context = sc;
|
||||
if (procHeader.name.meth_name is template_type_name)
|
||||
{
|
||||
procHeader.template_args = (procHeader.name.meth_name as template_type_name).template_args;
|
||||
ident id = new ident(procHeader.name.meth_name.name);
|
||||
procHeader.name.meth_name = id;
|
||||
}
|
||||
procHeader.parameters = formalPars;
|
||||
procHeader.of_object = ofObject;
|
||||
procHeader.class_keyword = classKeyword;
|
||||
procHeader.return_type = returnType;
|
||||
|
||||
statement_list stmtList = new statement_list();
|
||||
stmtList.subnodes.Add(procBody);
|
||||
|
||||
block bl = new block(null, null);
|
||||
bl.program_code = stmtList;
|
||||
|
||||
procDef.proc_header = procHeader;
|
||||
procDef.proc_body = (proc_block)bl;
|
||||
|
||||
return procDef;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public class SubtreeCreator
|
||||
{
|
||||
/// <summary>
|
||||
/// Создать var-выражение
|
||||
/// </summary>
|
||||
/// <param name="name">Имя переменной</param>
|
||||
/// <param name="initialValue">Начальное значение</param>
|
||||
/// <returns></returns>
|
||||
public static var_def_statement CreateVarDef(string name, expression initialValue)
|
||||
{
|
||||
ident_list list = new ident_list();
|
||||
list.idents.Add(new ident(name));
|
||||
var res = new var_def_statement();
|
||||
res.inital_value = initialValue;
|
||||
res.vars = list;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Объявление пременной с именованным типом
|
||||
/// </summary>
|
||||
/// <param name="variableName"></param>
|
||||
/// <param name="typeName"></param>
|
||||
/// <returns></returns>
|
||||
public static var_statement NamedTypeVariableDefinition(string variableName, string typeName)
|
||||
{
|
||||
var_def_statement varDefStatement = new var_def_statement();
|
||||
varDefStatement.vars.Add(new ident(variableName));
|
||||
varDefStatement.vars_type = new named_type_reference(typeName);
|
||||
return new var_statement(varDefStatement);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создать var-выражение с несколькими переменными
|
||||
/// </summary>
|
||||
/// <param name="type">Тип переменных</param>
|
||||
/// <param name="idents">Имена переменных</param>
|
||||
/// <returns></returns>
|
||||
public static var_def_statement CreateVarDef(named_type_reference type, params string[] names)
|
||||
{
|
||||
var_def_statement res = new var_def_statement();
|
||||
foreach (string x in names)
|
||||
res.vars.Add(new ident(x));
|
||||
res.vars_type = type;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создать цикл for
|
||||
/// </summary>
|
||||
/// <param name="varName">Имя переменной цикла</param>
|
||||
/// <param name="initValue">Начальное значение переменной цикла</param>
|
||||
/// <param name="finishValue">Конечное значение переменной цикла</param>
|
||||
/// <param name="body">Тело цикла</param>
|
||||
/// <param name="type">Тип цикла(to / downto)</param>
|
||||
/// <returns></returns>
|
||||
public static SyntaxTree.for_node CreateFor(string varName, expression initValue, expression finishValue, statement body, for_cycle_type type)
|
||||
{
|
||||
SyntaxTree.for_node res = new SyntaxTree.for_node();
|
||||
res.loop_variable = new ident(varName);
|
||||
res.initial_value = initValue;
|
||||
res.finish_value = finishValue;
|
||||
res.statements = body;
|
||||
res.cycle_type = type;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создать цикл while
|
||||
/// </summary>
|
||||
/// <param name="condition">Условие цикла</param>
|
||||
/// <param name="body">Тело цикла</param>
|
||||
/// <returns></returns>
|
||||
public static SyntaxTree.while_node CreateWhile(expression condition, statement body)
|
||||
{
|
||||
SyntaxTree.while_node res = new SyntaxTree.while_node();
|
||||
res.CycleType = WhileCycleType.While;
|
||||
res.expr = condition;
|
||||
res.statements = body;
|
||||
return res;
|
||||
}
|
||||
|
||||
private static SyntaxTree.if_node CreateIfElse(expression condition, statement thenBody, statement elseBody)
|
||||
{
|
||||
return new SyntaxTree.if_node(condition, thenBody, elseBody);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создать условный оператор
|
||||
/// </summary>
|
||||
/// <param name="condition">Условие</param>
|
||||
/// <param name="thenBody">Тело, выполняемое если условие истино</param>
|
||||
/// <returns></returns>
|
||||
public static SyntaxTree.if_node CreateIf(expression condition, statement thenBody)
|
||||
{
|
||||
return CreateIfElse(condition, thenBody, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создать условный оператор
|
||||
/// </summary>
|
||||
/// <param name="condition">Условие</param>
|
||||
/// <param name="thenBody">Тело, выполняемое если условие истино</param>
|
||||
/// <param name="elseBody">Тело, выполняемое если условие ложно</param>
|
||||
/// <returns></returns>
|
||||
public static SyntaxTree.if_node CreateIf(expression condition, statement thenBody, statement elseBody)
|
||||
{
|
||||
return CreateIfElse(condition, thenBody, elseBody);
|
||||
}
|
||||
|
||||
private static SyntaxTree.program_module InternalCreateProgramModule(statement_list statements, declarations defs)
|
||||
{
|
||||
block block = new block();
|
||||
if (defs != null)
|
||||
block.defs = defs;
|
||||
statements.Add(new SyntaxTree.empty_statement());
|
||||
statements.left_logical_bracket = new token_info("begin");
|
||||
statements.right_logical_bracket = new token_info("end");
|
||||
block.program_code = statements;
|
||||
|
||||
program_module res = new program_module();
|
||||
res.program_block = block;
|
||||
//res.used_units = create_standard_uses_list();
|
||||
return res;
|
||||
}
|
||||
|
||||
public static SyntaxTree.program_module CreateProgramModule(statement_list statements, declarations defs)
|
||||
{
|
||||
return InternalCreateProgramModule(statements, defs);
|
||||
}
|
||||
|
||||
public static SyntaxTree.program_module CreateProgramModule(statement_list statements)
|
||||
{
|
||||
return InternalCreateProgramModule(statements, null);
|
||||
}
|
||||
|
||||
//private SyntaxTree.uses_list CreateStandartUsesList()
|
||||
//{
|
||||
// uses_list res = new uses_list();
|
||||
// unit_or_namespace pabcsystem = new unit_or_namespace();
|
||||
// pabcsystem.name = new ident_list("PABCSystem");
|
||||
// res.units.Add(pabcsystem);
|
||||
// return res;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Создает узел вызова процедуры из PABCSystem
|
||||
/// </summary>
|
||||
/// <param name="procName">Имя процедуры</param>
|
||||
/// <param name="exprList">Параметры процедуры</param>
|
||||
/// <returns></returns>
|
||||
public static procedure_call CreateSystemProcedureCall(string procName, params expression[] exprList)
|
||||
{
|
||||
var procedureCall = CreateProcedureCall(procName, exprList);
|
||||
(procedureCall.func_name as method_call).dereferencing_value = new dot_node(new ident("PABCSystem"), new ident(procName));
|
||||
|
||||
return procedureCall;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создает узел вызова функции из PABCSystem
|
||||
/// </summary>
|
||||
/// <param name="funcName">Имя функции</param>
|
||||
/// <param name="exprList">Параметры функции</param>
|
||||
/// <returns></returns>
|
||||
public static method_call CreateSystemFunctionCall(string funcName, params expression[] exprList)
|
||||
{
|
||||
return CreateMethodCall(funcName, "PABCSystem", exprList);
|
||||
}
|
||||
|
||||
public static method_call CreateMethodCall(string funcName, string qualifier, params expression[] exprList)
|
||||
{
|
||||
var methodCall = CreateMethodCall(funcName, exprList);
|
||||
methodCall.dereferencing_value = new dot_node(new ident(qualifier), new ident(funcName));
|
||||
return methodCall;
|
||||
}
|
||||
|
||||
public static procedure_call CreateProcedureCall(string procName, params expression[] exprList)
|
||||
{
|
||||
SyntaxTree.procedure_call pc = new SyntaxTree.procedure_call();
|
||||
pc.func_name = CreateMethodCall(procName, exprList);
|
||||
return pc;
|
||||
}
|
||||
|
||||
private static method_call CreateMethodCall(string methodName, params expression[] exprList)
|
||||
{
|
||||
SyntaxTree.method_call mc = new SyntaxTree.method_call();
|
||||
mc.dereferencing_value = new ident(methodName);
|
||||
SyntaxTree.expression_list exl = new PascalABCCompiler.SyntaxTree.expression_list();
|
||||
foreach (expression x in exprList)
|
||||
exl.Add(x);
|
||||
mc.parameters = exl;
|
||||
|
||||
return mc;
|
||||
}
|
||||
|
||||
// From LamdaHelper
|
||||
private static procedure_definition InternalCreateProcedureDefinitionNode(string methName, formal_parameters formalPars, bool classKeyword, statement procBody, SourceContext sc)
|
||||
{
|
||||
return SyntaxTreeNodesConstructor.CreateProcedureDefinitionNode(new method_name(methName),
|
||||
formalPars,
|
||||
false,
|
||||
classKeyword,
|
||||
procBody,
|
||||
sc);
|
||||
}
|
||||
|
||||
public static procedure_definition CreateProcedureDefinitionNode(string methName, formal_parameters formalPars, bool classKeyword, statement procBody, SourceContext sc)
|
||||
{
|
||||
return InternalCreateProcedureDefinitionNode(methName, formalPars, classKeyword, procBody, sc);
|
||||
}
|
||||
|
||||
public static procedure_definition CreateProcedureDefinitionNode(string methName, formal_parameters formalPars, bool classKeyword, statement procBody)
|
||||
{
|
||||
return InternalCreateProcedureDefinitionNode(methName, formalPars, classKeyword, procBody, null);
|
||||
}
|
||||
|
||||
private static procedure_definition InternalCreateFunctionDefinitionNode(string methName, formal_parameters formalPars, bool classKeyword, statement procBody, type_definition returnType, SourceContext sc)
|
||||
{
|
||||
return SyntaxTreeNodesConstructor.CreateFunctionDefinitionNode(new method_name(methName),
|
||||
formalPars,
|
||||
false,
|
||||
classKeyword,
|
||||
procBody,
|
||||
returnType,
|
||||
sc);
|
||||
}
|
||||
|
||||
public static procedure_definition CreateFunctionDefinitionNode(string methName, formal_parameters formalPars, bool classKeyword, statement procBody, type_definition returnType, SourceContext sc)
|
||||
{
|
||||
return InternalCreateFunctionDefinitionNode(methName, formalPars, classKeyword, procBody, returnType, sc);
|
||||
}
|
||||
|
||||
public static procedure_definition CreateFunctionDefinitionNode(string methName, formal_parameters formalPars, bool classKeyword, statement procBody, type_definition returnType)
|
||||
{
|
||||
return InternalCreateFunctionDefinitionNode(methName, formalPars, classKeyword, procBody, returnType, null);
|
||||
}
|
||||
// From !LamdaHelper
|
||||
|
||||
public static declarations CreateDeclarations(params declaration[] decls)
|
||||
{
|
||||
declarations res = new declarations();
|
||||
foreach (declaration x in decls)
|
||||
res.Add(x);
|
||||
return res;
|
||||
}
|
||||
|
||||
public static statement_list CreateStatementList(params statement[] stmts)
|
||||
{
|
||||
statement_list res = new statement_list();
|
||||
foreach (statement x in stmts)
|
||||
res.Add(x);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
public class SyntaxTreeBuilder
|
||||
{
|
||||
public static SourceContext BuildGenSC = new SourceContext(0, 777777, 0, 0, 0, 0);
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ using System.Diagnostics;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using PascalABCCompiler.SyntaxTree;
|
||||
using PascalABCCompiler.TreeConversion;
|
||||
using PascalABCCompiler.TreeConverter;
|
||||
|
||||
namespace SyntaxVisitors.PatternsVisitors
|
||||
{
|
||||
|
|
@ -86,11 +84,11 @@ namespace SyntaxVisitors.PatternsVisitors
|
|||
{
|
||||
private enum PatternLocation { Unknown, IfCondition, Assign }
|
||||
|
||||
private const string DeconstructMethodName = compiler_string_consts.deconstruct_method_name;
|
||||
private const string IsTestMethodName = compiler_string_consts.is_test_function_name;
|
||||
private const string WildCardsTupleEqualFunctionName = compiler_string_consts.wild_cards_tuple_equal_function_name;
|
||||
private const string SeqFunctionName = compiler_string_consts.seq_function_name;
|
||||
private const string CountPropertyName = compiler_string_consts.count_property_name;
|
||||
private const string DeconstructMethodName = "deconstruct";
|
||||
private const string IsTestMethodName = "__TypeCheckAndAssignForIsMatch";
|
||||
private const string WildCardsTupleEqualFunctionName = "__WildCardsTupleEqual";
|
||||
private const string SeqFunctionName = "Seq";
|
||||
private const string CountPropertyName = "Count";
|
||||
private const string GeneratedPatternNamePrefix = "<>pattern";
|
||||
private const string GeneratedDeconstructParamPrefix = "<>deconstructParam";
|
||||
private const string GeneratedVisitElseBranchVariableName = "<>visitElseBranch";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using PascalABCCompiler.SyntaxTree;
|
||||
using PascalABCCompiler.TreeConverter;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
@ -9,6 +8,8 @@ namespace SyntaxVisitors
|
|||
{
|
||||
public class SingleDeconstructChecker : BaseEnterExitVisitor
|
||||
{
|
||||
private const string DeconstructMethodName = "deconstruct"; // в трех местах эту константу - если менять
|
||||
|
||||
private int deconstructCount = 0;
|
||||
private bool isInClass = false;
|
||||
|
||||
|
|
@ -34,7 +35,7 @@ namespace SyntaxVisitors
|
|||
if (!isInClass)
|
||||
return;
|
||||
|
||||
if (_method_name?.meth_name?.name?.ToLower() == compiler_string_consts.deconstruct_method_name)
|
||||
if (_method_name?.meth_name?.name?.ToLower() == DeconstructMethodName)
|
||||
deconstructCount++;
|
||||
|
||||
if (deconstructCount > 1)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Linq;
|
|||
using System.Text;
|
||||
|
||||
using PascalABCCompiler.SyntaxTree;
|
||||
using PascalABCCompiler.TreeRealization;
|
||||
|
||||
namespace SyntaxVisitors.SugarVisitors
|
||||
{
|
||||
|
|
@ -71,7 +70,7 @@ namespace SyntaxVisitors.SugarVisitors
|
|||
{
|
||||
if (param is unpacked_list_of_ident_or_list unpacked_param)
|
||||
{
|
||||
var lam_inft = new lambda_inferred_type(new lambda_any_type_node());
|
||||
var lam_inft = new lambda_inferred_type(new lambda_any_type_node_syntax());
|
||||
var param_id = CreateIdent(fld.source_context);
|
||||
var idlist = new ident_list(param_id, unpacked_param.source_context);
|
||||
var typed_pars = new typed_parameters(idlist, lam_inft, parametr_kind.none, null, unpacked_param.source_context);
|
||||
|
|
@ -83,7 +82,7 @@ namespace SyntaxVisitors.SugarVisitors
|
|||
}
|
||||
else if (param is ident id)
|
||||
{
|
||||
var lam_inft = new lambda_inferred_type(new lambda_any_type_node());
|
||||
var lam_inft = new lambda_inferred_type(new lambda_any_type_node_syntax());
|
||||
var idlist = new ident_list(id,id.source_context);
|
||||
var typed_pars = new typed_parameters(idlist, lam_inft);
|
||||
fld.formal_parameters.Add(typed_pars, fld.source_context);
|
||||
|
|
|
|||
|
|
@ -116,10 +116,6 @@
|
|||
<Project>{c2cac65a-b2ae-4ccc-b067-e6b8e75df73a}</Project>
|
||||
<Name>SyntaxTree</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\TreeConverter\TreeConverter.csproj">
|
||||
<Project>{1C9C945A-586D-42A2-A06B-65D84FA7FF78}</Project>
|
||||
<Name>TreeConverter</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Yield\YieldHelpers\YieldHelpers.csproj">
|
||||
<Project>{ce5c55c2-a11c-4e94-a9fa-3fc6ca3e4c09}</Project>
|
||||
<Name>YieldHelpers</Name>
|
||||
|
|
|
|||
|
|
@ -459,7 +459,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}*/
|
||||
}
|
||||
#endregion
|
||||
|
||||
/*
|
||||
#region Генерация новых узлов синтаксического дерева
|
||||
/// <summary>
|
||||
/// Класс для генерации новых узлов синтаксического дерева
|
||||
|
|
@ -549,5 +549,6 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
}
|
||||
#endregion
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using PascalABCCompiler.TreeConverter;
|
|||
|
||||
namespace PascalABCCompiler.TreeConversion
|
||||
{
|
||||
/*
|
||||
public class SubtreeCreator
|
||||
{
|
||||
syntax_tree_visitor _syntaxTreeVisitor;
|
||||
|
|
@ -278,4 +279,5 @@ namespace PascalABCCompiler.TreeConversion
|
|||
return res;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,11 +373,11 @@ namespace PascalABCCompiler.TreeConverter
|
|||
public static string ienumerable_auto_type_name = "IEnumerableAutoType"; // SSM 05.07.16 - тип, который определяется на этапе компиляции при первом присваивании
|
||||
public static string recort_printable_name_template = "record{0}end";
|
||||
public static string set_name = "TypedSet";
|
||||
public const string deconstruct_method_name = "deconstruct";
|
||||
public const string is_test_function_name = "__TypeCheckAndAssignForIsMatch";
|
||||
public const string wild_cards_tuple_equal_function_name = "__WildCardsTupleEqual";
|
||||
public const string seq_function_name = "Seq";
|
||||
public const string count_property_name = "Count";
|
||||
public const string deconstruct_method_name = "deconstruct"; // Есть дубль - если менять здесь, то и в дубле!!
|
||||
//public const string is_test_function_name = "__TypeCheckAndAssignForIsMatch";
|
||||
//public const string wild_cards_tuple_equal_function_name = "__WildCardsTupleEqual";
|
||||
//public const string seq_function_name = "Seq";
|
||||
//public const string count_property_name = "Count";
|
||||
public static string bounded_array_printable_name_template = "array [{0}..{1}] of {2}";
|
||||
public static string array_printable_name_template = "array of {0}";
|
||||
public static string multi_dim_array_printable_name_template = "array [{0}] of {1}";
|
||||
|
|
|
|||
Loading…
Reference in a new issue