2019-07-28 23:53:15 +03:00
|
|
|
|
// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
|
2017-02-19 16:29:24 +03:00
|
|
|
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
|
|
|
|
using System;
|
2017-01-12 13:51:16 +03:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using PascalABCCompiler.SyntaxTree;
|
2017-01-12 15:42:16 +03:00
|
|
|
|
using SyntaxVisitors;
|
2017-01-19 14:21:03 +03:00
|
|
|
|
using SyntaxVisitors.SugarVisitors;
|
2017-01-12 13:51:16 +03:00
|
|
|
|
|
|
|
|
|
|
namespace PascalABCCompiler.SyntaxTreeConverters
|
|
|
|
|
|
{
|
|
|
|
|
|
public class StandardSyntaxTreeConverter: ISyntaxTreeConverter
|
|
|
|
|
|
{
|
|
|
|
|
|
public string Name { get; } = "Standard";
|
|
|
|
|
|
public syntax_tree_node Convert(syntax_tree_node root)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Прошивание ссылками на Parent nodes. Должно идти первым
|
2017-01-12 15:42:16 +03:00
|
|
|
|
// FillParentNodeVisitor расположен в SyntaxTree/tree как базовый визитор, отвечающий за построение дерева
|
2018-10-24 20:39:07 +03:00
|
|
|
|
//FillParentNodeVisitor.New.ProcessNode(root); // почему-то перепрошивает не всё. А следующий вызов - всё
|
|
|
|
|
|
root.FillParentsInAllChilds();
|
2017-01-12 13:51:16 +03:00
|
|
|
|
// Выносим выражения с лямбдами из заголовка foreach
|
2017-01-12 15:42:16 +03:00
|
|
|
|
StandOutExprWithLambdaInForeachSequenceVisitor.New.ProcessNode(root);
|
2019-06-15 13:25:44 +03:00
|
|
|
|
VarNamesInMethodsWithSameNameAsClassGenericParamsReplacer.New.ProcessNode(root); // SSM bug fix #1147
|
2019-06-29 19:28:18 +03:00
|
|
|
|
FindOnExceptVarsAndApplyRenameVisitor.New.ProcessNode(root);
|
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
|
2017-01-20 19:56:43 +03:00
|
|
|
|
AssignTuplesDesugarVisitor.New.ProcessNode(root);
|
|
|
|
|
|
|
2017-01-22 20:54:13 +03:00
|
|
|
|
// slice_expr и slice_expr_question
|
2017-01-26 15:47:13 +03:00
|
|
|
|
SliceDesugarVisitor.New.ProcessNode(root);
|
2017-01-19 14:21:03 +03:00
|
|
|
|
|
2017-05-08 22:59:52 +03:00
|
|
|
|
// question_point_desugar_visitor
|
|
|
|
|
|
QuestionPointDesugarVisitor.New.ProcessNode(root);
|
2017-02-03 11:31:40 +03:00
|
|
|
|
|
2017-06-03 00:30:15 +03:00
|
|
|
|
// double_question_desugar_visitor
|
|
|
|
|
|
DoubleQuestionDesugarVisitor.New.ProcessNode(root);
|
|
|
|
|
|
|
2018-05-11 13:46:59 +03:00
|
|
|
|
// Patterns
|
2018-10-21 12:29:36 +03:00
|
|
|
|
// SingleDeconstructChecker.New.ProcessNode(root); // SSM 21.10.18 - пока разрешил множественные деконструкторы. Если будут проблемы - запретить
|
2019-05-28 09:21:59 +03:00
|
|
|
|
ExtendedIsDesugaringVisitor.New.ProcessNode(root); // Десахаризация расширенного is, который используется в сложных логических выражениях
|
|
|
|
|
|
PatternsDesugaringVisitor.New.ProcessNode(root); // Обязательно в этом порядке.
|
2017-02-03 11:31:40 +03:00
|
|
|
|
|
2018-12-05 11:36:45 +03:00
|
|
|
|
// simple_property
|
|
|
|
|
|
PropertyDesugarVisitor.New.ProcessNode(root);
|
|
|
|
|
|
|
2017-01-12 15:42:16 +03:00
|
|
|
|
// Всё, связанное с yield
|
2018-10-26 20:12:42 +03:00
|
|
|
|
CapturedNamesHelper.Reset();
|
2017-01-30 10:19:35 +03:00
|
|
|
|
MarkMethodHasYieldAndCheckSomeErrorsVisitor.New.ProcessNode(root);
|
2017-01-12 15:42:16 +03:00
|
|
|
|
ProcessYieldCapturedVarsVisitor.New.ProcessNode(root);
|
|
|
|
|
|
|
2018-05-20 20:22:43 +03:00
|
|
|
|
#if DEBUG
|
2018-09-27 17:59:37 +03:00
|
|
|
|
//new SimplePrettyPrinterVisitor("D:\\Tree.txt").ProcessNode(root);
|
2018-05-20 20:22:43 +03:00
|
|
|
|
//FillParentNodeVisitor.New.ProcessNode(root);
|
2018-05-17 22:49:07 +03:00
|
|
|
|
|
2018-11-08 00:24:28 +03:00
|
|
|
|
|
2017-11-16 23:10:30 +03:00
|
|
|
|
/*var cv = CollectLightSymInfoVisitor.New;
|
|
|
|
|
|
cv.ProcessNode(root);
|
|
|
|
|
|
cv.Output(@"Light1.txt");*/
|
2018-11-08 00:24:28 +03:00
|
|
|
|
|
2019-07-11 23:21:02 +03:00
|
|
|
|
/*try
|
2017-10-20 11:54:32 +03:00
|
|
|
|
{
|
2019-07-08 21:52:13 +03:00
|
|
|
|
root.visit(new SimplePrettyPrinterVisitor(@"d:\\zzz1.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
|
|
|
|
{
|
|
|
|
|
|
|
2019-07-08 21:52:13 +03:00
|
|
|
|
System.IO.File.AppendAllText(@"d:\\zzz1.txt",e.Message);
|
2019-07-11 23:21:02 +03:00
|
|
|
|
}*/
|
2018-11-08 00:24:28 +03:00
|
|
|
|
|
2017-10-20 11:54:32 +03:00
|
|
|
|
|
|
|
|
|
|
#endif
|
2017-01-12 13:51:16 +03:00
|
|
|
|
return root;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|