private static string GetLack(RegulationList grammar, out bool error)
        {
            StringBuilder       builder  = new StringBuilder();
            List <TreeNodeType> lackList = new List <TreeNodeType>();
            var nonLeaveNodeList         = grammar.GetAllTreeNodeNonLeaveTypes();

            foreach (var regulation in grammar)
            {
                foreach (var node in regulation.RightPart)
                {
                    if ((!node.IsLeave) &&
                        (!nonLeaveNodeList.Contains(node)) &&
                        (!lackList.Contains(node)))
                    {
                        lackList.Add(node);
                    }
                }
            }

            builder.AppendLine("====================================================================");
            builder.AppendLine(string.Format("Lack of [{0}] regulation's definitions:", lackList.Count));
            foreach (var item in lackList)
            {
                builder.AppendLine(string.Format("{0}", item.Dump()));
            }

            error = lackList.Count > 0;

            return(builder.ToString());
        }
        private static string GetUnused(RegulationList grammar, out bool error)
        {
            StringBuilder       builder  = new StringBuilder();
            List <TreeNodeType> usedList = new List <TreeNodeType>();

            usedList.Add(grammar[0].Left);
            bool changed = false;
            int  index   = 0;

            do
            {
                changed = false;
                int count = usedList.Count;
                for (; index < count; index++)
                {
                    TreeNodeType node = usedList[index];
                    foreach (var regulation in grammar)
                    {
                        if (regulation.Left == node)
                        {
                            foreach (var item in regulation.RightPart)
                            {
                                if ((!item.IsLeave) && (!usedList.Contains(item)))
                                {
                                    usedList.Add(item);
                                    changed = true;
                                }
                            }
                        }
                    }
                }
            } while (changed);

            List <TreeNodeType> unusedList          = new List <TreeNodeType>();
            List <TreeNodeType> allNonLeaveNodeList = grammar.GetAllTreeNodeNonLeaveTypes();

            foreach (var node in allNonLeaveNodeList)
            {
                if (!usedList.Contains(node))
                {
                    unusedList.Add(node);
                }
            }
            builder.AppendLine("====================================================================");
            builder.AppendLine(string.Format("{0} unused nodes:", unusedList.Count));
            foreach (var item in unusedList)
            {
                builder.AppendLine(item.Dump());
            }

            error = unusedList.Count > 0;

            return(builder.ToString());
        }