Перенес StandardSyntaxConverter.cs в проект SyntaxTreeConverters.csproj

This commit is contained in:
miks1965 2017-01-30 10:19:35 +03:00
parent a72a2c8bd3
commit a14960b048
15 changed files with 119 additions and 192 deletions

View file

@ -142,10 +142,6 @@
<Project>{613E0DDA-AA8A-437C-AC45-507B47429FF9}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
</ProjectReference>
<ProjectReference Include="..\StandardSyntaxTreeConverter\StandardSyntaxTreeConverter.csproj">
<Project>{4d36d4ce-56fd-4bec-b846-d54b3a39ffd5}</Project>
<Name>StandardSyntaxTreeConverter</Name>
</ProjectReference>
<ProjectReference Include="..\SyntaxTreeConverters\SyntaxTreeConverters.csproj">
<Project>{f10a5330-dcf4-4533-877c-7b1b1be23884}</Project>
<Name>SyntaxTreeConverters</Name>

View file

@ -1274,6 +1274,29 @@
</i>
</OCtx>
</Node>
<Node ID="visit" Name="Обработка auto_type в assign_node" NL="0,8925781" NG="-1">
<FileName>\TreeConverter\TreeConversion\syntax_tree_visitor.cs</FileName>
<Note>Обработка auto_type в assign_node</Note>
<Text>if (to.type is auto_type)</Text>
<OCtx>
<i Type="Method">public override void visit ( SyntaxTree . assign _assign )</i>
<i Type="ClassOrNamespace">public partial class syntax_tree_visitor : SyntaxTree . WalkingVisitorNew</i>
<i Type="ClassOrNamespace">namespace PascalABCCompiler . TreeConverter</i>
<i Type="CS_TreeNode">
</i>
</OCtx>
</Node>
<Node ID="visit" Name="visit(SyntaxTree.yield_unknown_expression_type" NL="0,9160156" NG="-1">
<FileName>\TreeConverter\TreeConversion\syntax_tree_visitor.cs</FileName>
<Text>public override void visit(SyntaxTree.yield_unknown_expression_type _unk_expr)</Text>
<OCtx>
<i Type="Method">public override void visit ( SyntaxTree . yield_unknown_expression_type _unk_expr )</i>
<i Type="ClassOrNamespace">public partial class syntax_tree_visitor : SyntaxTree . WalkingVisitorNew</i>
<i Type="ClassOrNamespace">namespace PascalABCCompiler . TreeConverter</i>
<i Type="CS_TreeNode">
</i>
</OCtx>
</Node>
</Items>
</Node>
<Node Name="a.Sort((row1, row2) -&gt; 1)" NL="0" NG="0">
@ -1391,6 +1414,20 @@
</Node>
<Node Name="Ядро преобраз-я синт. деревьев" NL="0" NG="0">
<Items>
<Node ID="StandardSyntaxTreeConverter" Name="StandardSyntaxTreeConverter" NL="-1" NG="0,2734375">
<FileName>\standardsyntaxtreeconverter\standardsyntaxconverter.cs</FileName>
<OCtx>
<i Type="ClassOrNamespace">public class StandardSyntaxTreeConverter : ISyntaxTreeConverter</i>
<i Type="ClassOrNamespace">namespace PascalABCCompiler . SyntaxTreeConverters</i>
<i Type="CS_TreeNode">
</i>
</OCtx>
<ICtx>
<i Type="Method">public string Name</i>
<i Type="Field">=</i>
<i Type="Method">public syntax_tree_node Convert ( syntax_tree_node root )</i>
</ICtx>
</Node>
<Node Name="SyntaxTree = Convert(SyntaxTree)" NL="0" NG="0">
<FileName>\Compiler\Compiler.cs</FileName>
<Text>CurrentUnit.SyntaxTree = syntaxTreeConvertersController.Convert(CurrentUnit.SyntaxTree) as SyntaxTree.compilation_unit;</Text>
@ -1449,20 +1486,6 @@
<i Type="Method">public syntax_tree_node Convert ( syntax_tree_node root )</i>
</ICtx>
</Node>
<Node ID="StandardSyntaxTreeConverter" Name="StandardSyntaxTreeConverter" NL="-1" NG="0,2734375">
<FileName>\standardsyntaxtreeconverter\standardsyntaxconverter.cs</FileName>
<OCtx>
<i Type="ClassOrNamespace">public class StandardSyntaxTreeConverter : ISyntaxTreeConverter</i>
<i Type="ClassOrNamespace">namespace PascalABCCompiler . SyntaxTreeConverters</i>
<i Type="CS_TreeNode">
</i>
</OCtx>
<ICtx>
<i Type="Method">public string Name</i>
<i Type="Field">=</i>
<i Type="Method">public syntax_tree_node Convert ( syntax_tree_node root )</i>
</ICtx>
</Node>
</Items>
</Node>
<Node Name="visit(SyntaxTree.dot_node" NL="0" NG="0">

View file

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualPascalABCNET", "VisualPascalABCNET", "{26843C5D-9D7E-4C2C-AC14-2D227FA5592E}"
EndProject
@ -101,8 +101,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntaxVisitors", "SyntaxVis
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YieldConversionSyntax", "Yield\YieldConversionSyntax\YieldConversionSyntax.csproj", "{276EE073-60F6-46D2-8811-1B8026BCAADA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StandardSyntaxTreeConverter", "StandardSyntaxTreeConverter\StandardSyntaxTreeConverter.csproj", "{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -455,18 +453,6 @@ Global
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|x86.ActiveCfg = Release|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Debug|x86.ActiveCfg = Debug|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Debug|x86.Build.0 = Debug|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Release|Any CPU.Build.0 = Release|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Release|x86.ActiveCfg = Release|Any CPU
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -509,6 +495,5 @@ Global
{CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09} = {F8CE2712-826B-450B-A72F-D32D80C99858}
{A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2} = {F8CE2712-826B-450B-A72F-D32D80C99858}
{276EE073-60F6-46D2-8811-1B8026BCAADA} = {F8CE2712-826B-450B-A72F-D32D80C99858}
{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5} = {F8CE2712-826B-450B-A72F-D32D80C99858}
EndGlobalSection
EndGlobal

View file

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Управление общими сведениями о сборке осуществляется с помощью
// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
// связанные со сборкой.
[assembly: AssemblyTitle("StandardSyntaxTreeConverter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StandardSyntaxTreeConverter")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Параметр ComVisible со значением FALSE делает типы в сборке невидимыми
// для COM-компонентов. Если требуется обратиться к типу в этой сборке через
// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("4d36d4ce-56fd-4bec-b846-d54b3a39ffd5")]
// Сведения о версии сборки состоят из следующих четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -1,38 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using PascalABCCompiler.SyntaxTree;
public class StandOutExprWithLambdaInForeachSequenceVisitor : BaseChangeVisitor
{
public static StandOutExprWithLambdaInForeachSequenceVisitor New
{
get
{
return new StandOutExprWithLambdaInForeachSequenceVisitor();
}
}
private int GenIdNum = 0;
public ident GenIdentName()
{
GenIdNum++;
return new ident("$GenContFE" + GenIdNum.ToString());
}
public override void visit(foreach_stmt fe)
{
if (fe.in_what.DescendantNodes().OfType<function_lambda_definition>().Count()>0)
{
var id = GenIdentName();
id.Parent = fe;
var ass = new var_statement(id, fe.in_what, fe.in_what.source_context);
fe.in_what = id;
var l = new List<statement> { ass,fe };
ReplaceStatement(fe, l);
}
base.visit(fe);
}
}

View file

@ -1,72 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" 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>{4D36D4CE-56FD-4BEC-B846-D54B3A39FFD5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StandardSyntaxTreeConverter</RootNamespace>
<AssemblyName>StandardSyntaxTreeConverter</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\</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.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StandardSyntaxConverter.cs" />
<Compile Include="StandOutExprWithLambdaInForeachSequenceVisitor.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="..\Yield\YieldConversionSyntax\YieldConversionSyntax.csproj">
<Project>{276ee073-60f6-46d2-8811-1b8026bcaada}</Project>
<Name>YieldConversionSyntax</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.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -37854,7 +37854,7 @@ namespace PascalABCCompiler.SyntaxTree
///<summary>
///Узел для вычисления типа выражения используемого в теле функции-итератора (с yield)
///Узел для вычисления типа выражения используемого в теле функции-итератора (с yield). Используется для описаний всех переменных с автовыводом типов в теле yield: например, для var a := 1; Дело в том, что эти переменные становятся полями класса, а для описания полей класса нужен тип
///</summary>
[Serializable]
public partial class yield_unknown_expression_type : type_definition

Binary file not shown.

View file

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PascalABCCompiler.SyntaxTreeConverters
{
class StandardSyntaxConverters: ISyntaxTreeConverter
{
public string Name { get; } = "Standard";
public syntax_tree_node Convert(syntax_tree_node root)
{
//var v = new SampleVisitor();
//v.ProcessNode(root);
return root;
}
}
}

View file

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using PascalABCCompiler.SyntaxTree;
namespace PascalABCCompiler.SyntaxTreeConverters
{
public class StandOutExprWithLambdaInForeachSequenceVisitor : BaseChangeVisitor
{
public static StandOutExprWithLambdaInForeachSequenceVisitor New
{
get
{
return new StandOutExprWithLambdaInForeachSequenceVisitor();
}
}
private int GenIdNum = 0;
public ident GenIdentName()
{
GenIdNum++;
return new ident("$GenContFE" + GenIdNum.ToString());
}
public override void visit(foreach_stmt fe)
{
if (fe.in_what.DescendantNodes().OfType<function_lambda_definition>().Count() > 0)
{
var id = GenIdentName();
id.Parent = fe;
var ass = new var_statement(id, fe.in_what, fe.in_what.source_context);
fe.in_what = id;
var l = new List<statement> { ass, fe };
ReplaceStatement(fe, l);
}
base.visit(fe);
}
}
}

View file

@ -32,10 +32,9 @@ namespace PascalABCCompiler.SyntaxTreeConverters
SliceDesugarVisitor.New.ProcessNode(root);
// Всё, связанное с yield
root.visit(new MarkMethodHasYieldAndCheckSomeErrorsVisitor());
MarkMethodHasYieldAndCheckSomeErrorsVisitor.New.ProcessNode(root);
ProcessYieldCapturedVarsVisitor.New.ProcessNode(root);
return root;
}
}

View file

@ -36,6 +36,8 @@
<ItemGroup>
<Compile Include="ISyntaxTreeConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StandardSyntaxConverter.cs" />
<Compile Include="StandOutExprWithLambdaInForeachSequenceVisitor.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Errors\Errors.csproj">
@ -50,6 +52,10 @@
<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>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -17,6 +17,11 @@ namespace SyntaxVisitors
private Stack<procedure_definition> MethodsStack = new Stack<procedure_definition>();
public static MarkMethodHasYieldAndCheckSomeErrorsVisitor New
{
get { return new MarkMethodHasYieldAndCheckSomeErrorsVisitor(); }
}
public override void visit(function_lambda_definition ld)
{
if (ld.DescendantNodes().OfType<yield_node>().Count() > 0)

View file

@ -19297,6 +19297,15 @@ namespace PascalABCCompiler.TreeConverter
}
}
public override void visit(SyntaxTree.yield_node yn)
{
// надо что то сгенерировать, иначе выдается ложное предупреждение о недостижимом коде и проч.
/*var ass = new assign("Result", new nil_const());
visit(ass);
var pc = new procedure_call("exit");
visit(pc);*/
}
// frninja - захват полей класса для yield
public override void visit(SyntaxTree.yield_unknown_ident _unk)
{
@ -19318,15 +19327,6 @@ namespace PascalABCCompiler.TreeConverter
t.visit(this);
}
public override void visit(SyntaxTree.yield_node yn)
{
// надо что то сгенерировать, иначе выдается ложное предупреждение о недостижимом коде и проч.
var ass = new assign("Result", new nil_const());
visit(ass);
var pc = new procedure_call("exit");
visit(pc);
}
/*public SyntaxTree.question_colon_expression ConvertToQCE(dot_question_node dqn)
{
// Неверно работает. Пока не используется. Доделать

Binary file not shown.