pascalabcnet/SyntaxTreeConverters/StandardSyntaxConverter.cs
Mikhalkovich Stanislav e603b1fd6d Mikhalkovich в Copyright
Заготовка для школьного плагина образцов кода
2019-07-28 23:53:15 +03:00

85 lines
3.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (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)
{
// Прошивание ссылками на Parent nodes. Должно идти первым
// FillParentNodeVisitor расположен в SyntaxTree/tree как базовый визитор, отвечающий за построение дерева
//FillParentNodeVisitor.New.ProcessNode(root); // почему-то перепрошивает не всё. А следующий вызов - всё
root.FillParentsInAllChilds();
// Выносим выражения с лямбдами из заголовка foreach
StandOutExprWithLambdaInForeachSequenceVisitor.New.ProcessNode(root);
VarNamesInMethodsWithSameNameAsClassGenericParamsReplacer.New.ProcessNode(root); // SSM bug fix #1147
FindOnExceptVarsAndApplyRenameVisitor.New.ProcessNode(root);
#if DEBUG
//new SimplePrettyPrinterVisitor("E:/projs/out.txt").ProcessNode(root);
#endif
// loop
LoopDesugarVisitor.New.ProcessNode(root);
// tuple_node
TupleVisitor.New.ProcessNode(root);
// assign_tuple и assign_var_tuple
AssignTuplesDesugarVisitor.New.ProcessNode(root);
// slice_expr и slice_expr_question
SliceDesugarVisitor.New.ProcessNode(root);
// question_point_desugar_visitor
QuestionPointDesugarVisitor.New.ProcessNode(root);
// double_question_desugar_visitor
DoubleQuestionDesugarVisitor.New.ProcessNode(root);
// Patterns
// SingleDeconstructChecker.New.ProcessNode(root); // SSM 21.10.18 - пока разрешил множественные деконструкторы. Если будут проблемы - запретить
ExtendedIsDesugaringVisitor.New.ProcessNode(root); // Десахаризация расширенного is, который используется в сложных логических выражениях
PatternsDesugaringVisitor.New.ProcessNode(root); // Обязательно в этом порядке.
// simple_property
PropertyDesugarVisitor.New.ProcessNode(root);
// Всё, связанное с yield
CapturedNamesHelper.Reset();
MarkMethodHasYieldAndCheckSomeErrorsVisitor.New.ProcessNode(root);
ProcessYieldCapturedVarsVisitor.New.ProcessNode(root);
#if DEBUG
//new SimplePrettyPrinterVisitor("D:\\Tree.txt").ProcessNode(root);
//FillParentNodeVisitor.New.ProcessNode(root);
/*var cv = CollectLightSymInfoVisitor.New;
cv.ProcessNode(root);
cv.Output(@"Light1.txt");*/
/*try
{
root.visit(new SimplePrettyPrinterVisitor(@"d:\\zzz1.txt"));
}
catch(Exception e)
{
System.IO.File.AppendAllText(@"d:\\zzz1.txt",e.Message);
}*/
#endif
return root;
}
}
}