public List <PersonComponent> MaxSalaryEmployees()
        {
            IVisitor employeeVisitor = new EmployeeMaxSalaryVisitor();

            Root.Accept(employeeVisitor);
            return(employeeVisitor.Employees);
        }
예제 #2
0
        /// <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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        /// <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());
        }
예제 #7
0
 public void Run(Root root)
 {
     root.Accept(this);
     OnEnd();
 }
예제 #8
0
 public static void Check(Root root, DiagnosticsReport diagnostics)
 => root.Accept(new Visitor(root, diagnostics));