2017-01-12 13:51:16 +03:00
|
|
|
|
using System;
|
|
|
|
|
|
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-01-12 13:51:16 +03:00
|
|
|
|
FillParentNodeVisitor.New.ProcessNode(root);
|
|
|
|
|
|
|
|
|
|
|
|
// Выносим выражения с лямбдами из заголовка 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-01-12 15:42:16 +03:00
|
|
|
|
// Всё, связанное с yield
|
|
|
|
|
|
root.visit(new MarkMethodHasYieldAndCheckSomeErrorsVisitor());
|
|
|
|
|
|
ProcessYieldCapturedVarsVisitor.New.ProcessNode(root);
|
|
|
|
|
|
|
2017-01-12 13:51:16 +03:00
|
|
|
|
|
|
|
|
|
|
return root;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|