private void AddTreeNode(int id, PegTree.AddPolicy newAddPolicy, CreatorPhase phase)
        {
            if(_mute)
            {
                return;
            }

            if(Tree.Root == null)
            {
                Tree.Root = Tree.Cur = CreateNode(phase, Tree.Cur, id);
            }
            else if(Tree.Policy == PegTree.AddPolicy.AddAsChild)
            {
                Tree.Cur = Tree.Cur.Child = CreateNode(phase, Tree.Cur, id);
            }
            else
            {
                Tree.Cur = Tree.Cur.Next = CreateNode(phase, Tree.Cur.Parent, id);
            }
            Tree.Policy = newAddPolicy;
        }
        private void RestoreTree(PegNode prevCur, PegTree.AddPolicy prevPolicy)
        {
            if(_mute)
            {
                return;
            }

            if(prevCur == null)
            {
                Tree.Root = null;
            }
            else if(prevPolicy == PegTree.AddPolicy.AddAsChild)
            {
                prevCur.Child = null;
            }
            else
            {
                prevCur.Next = null;
            }

            Tree.Cur = prevCur;
            Tree.Policy = prevPolicy;
        }
Exemplo n.º 3
0
        public void Load(string path)
        {
            _source = LoadFile(path);
            ConfigTableParser ctp = new ConfigTableParser(_source);

            try
            {
                bool parsed = ctp.Parse();

                if(parsed)
                {
                    _tree = ctp.Tree;
                }
                else
                {
                    throw new Exception("Parsing config file failed. Please check the configuration file.");
                }
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }