2017-02-19 16:29:24 +03:00
|
|
|
|
// 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;
|
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 как базовый визитор, отвечающий за построение дерева
|
2017-05-31 22:31:11 +03:00
|
|
|
|
FillParentNodeVisitor.New.ProcessNode(root);
|
2017-01-12 13:51:16 +03:00
|
|
|
|
|
|
|
|
|
|
// Выносим выражения с лямбдами из заголовка foreach
|
2017-01-12 15:42:16 +03:00
|
|
|
|
StandOutExprWithLambdaInForeachSequenceVisitor.New.ProcessNode(root);
|
|
|
|
|
|
|
2017-01-22 20:54:13 +03:00
|
|
|
|
//--- Обработка синтаксически сахарных узлов
|
|
|
|
|
|
|
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-05-13 20:49:08 +03:00
|
|
|
|
PatternsDesugaringVisitor.New.ProcessNode(root);
|
2017-02-03 11:31:40 +03:00
|
|
|
|
|
2018-05-17 15:20:16 +03:00
|
|
|
|
|
2018-05-17 22:49:07 +03:00
|
|
|
|
|
2018-05-17 02:07:10 +03:00
|
|
|
|
|
2017-01-12 15:42:16 +03:00
|
|
|
|
// Всё, связанное с yield
|
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 09:15:56 +03:00
|
|
|
|
//new SimplePrettyPrinterVisitor("G:\\Tree.txt").ProcessNode(root);
|
2018-05-17 22:49:07 +03:00
|
|
|
|
FillParentNodeVisitor.New.ProcessNode(root);
|
|
|
|
|
|
|
2017-10-20 11:54:32 +03:00
|
|
|
|
#if DEBUG
|
2017-10-26 19:39:20 +03:00
|
|
|
|
|
2017-11-16 23:10:30 +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
|
|
|
|
|
|
{
|
|
|
|
|
|
//root.visit(new SimplePrettyPrinterVisitor(@"d:\\zzz4.txt"));
|
|
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
2017-01-12 13:51:16 +03:00
|
|
|
|
return root;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|