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
|
|
|
|
//--- Обработка синтаксически сахарных узлов
|
|
|
|
|
|
|
|
|
|
|
|
// 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-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);
|
|
|
|
|
|
|
2017-04-28 22:52:03 +03:00
|
|
|
|
/*#if DEBUG
|
2017-02-18 00:19:27 +03:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2017-04-29 00:28:56 +03:00
|
|
|
|
//root.visit(new SimplePrettyPrinterVisitor(@"d:\\zzz4.txt"));
|
2017-02-18 00:19:27 +03:00
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-04-28 22:52:03 +03:00
|
|
|
|
#endif*/
|
2017-02-18 00:19:27 +03:00
|
|
|
|
|
2017-01-12 13:51:16 +03:00
|
|
|
|
return root;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|