public List <PersonComponent> MaxSalaryEmployees() { IVisitor employeeVisitor = new EmployeeMaxSalaryVisitor(); Root.Accept(employeeVisitor); return(employeeVisitor.Employees); }
/// <summary> /// Performs all actions /// <param name="tree">The tree on which to operate</param> /// </summary> public void Perform(Root tree) { if (tree == null) { return; } tree.Accept(this); var groups = new List <string>(); foreach (var action in this) { if (action.Group != null && groups.Contains(action.Group)) { continue; } if (BeforeAction != null) { BeforeAction(this, (EventArgs)action); } action.Execute(); if (AfterAction != null) { AfterAction(this, (EventArgs)action); } if (action.Group != null) { groups.Add(action.Group); } } }
public List <PersonComponent> MoreThanValueSalaryEmployees(int salary) { IVisitor visitor = new EmployeeMoreThanValueSalaryVisitor(salary); Root.Accept(visitor); var result = visitor.Employees; return(result); }
public List <PersonComponent> PositionEmployees(string position) { var visitor = new PositionVisitor(position); Root.Accept(visitor); var result = visitor.Employees; return(result); }
internal Graph Graph() { if (_graph == null) { //int id = 0; _currentNode = new ForestNodeNode(Root, "" + _id++, 0); _ids[Root.InternalNode] = 0; _graph = new Graph(_currentNode); //GetGraphHelper(g, myNode, new HashSet<InteriorNode>(), new Dictionary<InteriorNode, int> { { _node, 0 } }, ref id); Root.Accept(this); } return(_graph); }
/// <summary>Generates code</summary> /// <param name="tree">Root of a syntax tree</param> /// <param name="table">Table of symbols</param> /// <param name="columns">Columns layout</param> public void Generate(Root tree, SymbolTable table, ColumnsLayout columns = ColumnsLayout.FreeTextFormat) { Actions = new List<Action>(); // STEP 1: modify tree to adapt it to destination language tree.Accept(this); var groups = new List<string>(); foreach (var action in Actions) { if (action.Group != null && groups.Contains(action.Group)) continue; action.Execute(); if (action.Group != null) groups.Add(action.Group); } // Console.WriteLine(tree.Root.ToString()); // STEP 2: convert tree to destination language code var converter = new TreeToCode(Input, columns); tree.Accept(converter); converter.WriteInputLinesUntilEnd(); Writer.Write(converter.Output.ToString()); Writer.Flush(); // Console.WriteLine(converter.Output.ToString()); }
public void Run(Root root) { root.Accept(this); OnEnd(); }
public static void Check(Root root, DiagnosticsReport diagnostics) => root.Accept(new Visitor(root, diagnostics));