2015-06-28 10:53:10 +03:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
using PascalABCCompiler;
|
|
|
|
|
|
using PascalABCCompiler.SyntaxTree;
|
|
|
|
|
|
|
2015-08-17 21:15:22 +03:00
|
|
|
|
namespace SyntaxVisitors
|
2015-06-28 10:53:10 +03:00
|
|
|
|
{
|
2015-08-17 21:15:22 +03:00
|
|
|
|
public class CollectUpperNodesVisitor : BaseEnterExitVisitor
|
2015-06-28 10:53:10 +03:00
|
|
|
|
{
|
|
|
|
|
|
protected List<syntax_tree_node> listNodes = new List<syntax_tree_node>();
|
|
|
|
|
|
|
|
|
|
|
|
public syntax_tree_node CurrentNode
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return listNodes[listNodes.Count - 1];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public syntax_tree_node UpperNode(int up = 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
return listNodes[listNodes.Count - 1 - up];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Enter(syntax_tree_node st)
|
|
|
|
|
|
{
|
|
|
|
|
|
listNodes.Add(st);
|
|
|
|
|
|
}
|
|
|
|
|
|
public override void Exit(syntax_tree_node st)
|
|
|
|
|
|
{
|
|
|
|
|
|
listNodes.RemoveAt(listNodes.Count - 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|