pascalabcnet/SyntaxTreeConverters/StandardSyntaxConverter.cs

89 lines
3.7 KiB
C#
Raw Normal View History

// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PascalABCCompiler.SyntaxTree;
using SyntaxVisitors;
using SyntaxVisitors.SugarVisitors;
namespace PascalABCCompiler.SyntaxTreeConverters
{
public class StandardSyntaxTreeConverter: ISyntaxTreeConverter
{
public string Name { get; } = "Standard";
public syntax_tree_node Convert(syntax_tree_node root)
{
2018-09-26 21:48:50 +03:00
CapturedNamesHelper.Reset();
// Прошивание ссылками на Parent nodes. Должно идти первым
// FillParentNodeVisitor расположен в SyntaxTree/tree как базовый визитор, отвечающий за построение дерева
2017-05-31 22:31:11 +03:00
FillParentNodeVisitor.New.ProcessNode(root);
// Выносим выражения с лямбдами из заголовка foreach
StandOutExprWithLambdaInForeachSequenceVisitor.New.ProcessNode(root);
2018-10-20 11:08:27 +03:00
// type classes - пока закомментировал SSM 20/10/18. Грязный кусок кода. FillParentsInAllChilds вызывается повторно
2017-01-22 20:54:13 +03:00
2018-10-20 11:08:27 +03:00
/*{
2018-04-25 19:54:24 +03:00
var typeclasses = SyntaxVisitors.TypeclassVisitors.FindTypeclassesVisitor.New;
typeclasses.ProcessNode(root);
var instancesAndRestrictedFunctions = SyntaxVisitors.TypeclassVisitors.FindInstancesAndRestrictedFunctionsVisitor.New(typeclasses.typeclasses);
instancesAndRestrictedFunctions.ProcessNode(root);
SyntaxVisitors.TypeclassVisitors.ReplaceTypeclassVisitor.New(instancesAndRestrictedFunctions).ProcessNode(root);
}
2018-10-20 11:08:27 +03:00
root.FillParentsInAllChilds();*/
2018-06-28 22:12:52 +03:00
#if DEBUG
2018-05-17 03:00:10 +03:00
//new SimplePrettyPrinterVisitor("E:/projs/out.txt").ProcessNode(root);
2018-06-28 22:12:52 +03:00
#endif
2017-06-08 17:56:17 +03:00
// loop
LoopDesugarVisitor.New.ProcessNode(root);
2017-01-22 20:54:13 +03:00
// tuple_node
TupleVisitor.New.ProcessNode(root);
// assign_tuple и assign_var_tuple
AssignTuplesDesugarVisitor.New.ProcessNode(root);
2017-01-22 20:54:13 +03:00
// slice_expr и slice_expr_question
SliceDesugarVisitor.New.ProcessNode(root);
// question_point_desugar_visitor
QuestionPointDesugarVisitor.New.ProcessNode(root);
2017-02-03 11:31:40 +03:00
// double_question_desugar_visitor
DoubleQuestionDesugarVisitor.New.ProcessNode(root);
2018-05-11 13:46:59 +03:00
// Patterns
// SingleDeconstructChecker.New.ProcessNode(root); // SSM 21.10.18 - пока разрешил множественные деконструкторы. Если будут проблемы - запретить
PatternsDesugaringVisitor.New.ProcessNode(root);
2017-02-03 11:31:40 +03:00
// Всё, связанное с yield
MarkMethodHasYieldAndCheckSomeErrorsVisitor.New.ProcessNode(root);
ProcessYieldCapturedVarsVisitor.New.ProcessNode(root);
#if DEBUG
2018-09-27 17:59:37 +03:00
//new SimplePrettyPrinterVisitor("D:\\Tree.txt").ProcessNode(root);
//FillParentNodeVisitor.New.ProcessNode(root);
2018-05-17 22:49:07 +03:00
2017-10-26 19:39:20 +03:00
/*var cv = CollectLightSymInfoVisitor.New;
cv.ProcessNode(root);
cv.Output(@"Light1.txt");*/
2017-10-26 19:39:20 +03:00
2017-10-20 11:54:32 +03:00
/*try
{
2018-09-29 12:38:28 +03:00
root.visit(new SimplePrettyPrinterVisitor(@"d:\\zzz4.txt"));
2017-10-20 11:54:32 +03:00
}
2018-10-11 16:27:07 +03:00
catch(Exception e)
2017-10-20 11:54:32 +03:00
{
2018-10-11 16:27:07 +03:00
System.IO.File.AppendAllText(@"d:\\zzz4.txt",e.Message);
2017-10-20 11:54:32 +03:00
}*/
#endif
return root;
}
}
}