示例#1
0
        public void Init(ref TPredicateItemBig AHead, ref TPredicateTree APredicateTree)
        {
            string             SC;
            bool               pass;
            TPredicateItemBase Base, NC;

            f_PrStruct         = "";
            f_PrRab            = "";
            f_PrControlRab     = "";
            f_PrControlFunc    = "";
            f_PrCheckCondition = "";
            TDynamicArray m_Stack = new TDynamicArray();

            m_Stack.InsertToFirst(AHead);
            Base = (TPredicateItemBase)(m_Stack.Pop());
            while (Base != null)
            {
                NC = DoParseItem(ref Base, ref m_Stack);
                if (NC != null)
                {
                    f_BTree.insert(NC);
                }
                Base = (TPredicateItemBase)(m_Stack.Pop());
            }
            m_Stack = null;


            SharedConst.lcList.clear();
            f_BTree.inorder(acp);
            SharedConst.lcList.first();
            for (int i = 0; i <= SharedConst.lcList.length() - 1; i++)
            {
                //      TGlsListNode tmpNode = (TGlsListNode)SharedConst.lcList.val();
                //          TPredicateItemTFS tmpPredicateItem = (TPredicateItemTFS)(tmpNode.Val);
                //           TPredicateItemPWork
                Base = (TPredicateItemBase)(SharedConst.lcList.val());
                f_Item.Make(Base, Base.EnvelopeBIG);
                SC = f_Item.OutString;
                if (SC.Length > 0)
                {
                    f_PrStruct = f_PrStruct + SC + "\r\n";
                    MakeElement(Base);
                    if (APredicateTree != null)
                    {
                        AddElementToTree(APredicateTree);
                    }
                }
                //  MakeElement(Base);
                //  f_Tran.AddGTItem(f_Item);
                SharedConst.lcList.next();
            }

            bool acp(object A)
            {
                SharedConst.lcList.append(A);
                return(true);
            }

            // f_TextRecalc = f_Tran.Make();
        }
示例#2
0
 public TPredicateItemBase()
 {
     f_NumAlt      = -1;
     f_Envelope    = false;
     f_ID          = 0;
     f_EnvelopeBIG = null;
 }
示例#3
0
        TPredicatePathNode FillPathNode(TPredicateItemBig AHead, TDynamicArray ADyn)
        {
            int  m_who;
            bool valid = false;
            TPredicateItemBase Item;
            TPredicatePathNode N = null;
            TDynamicArray      D = new TDynamicArray();

            for (int i = 0; i <= ADyn.Count - 1; i++)
            {
                Item  = (TPredicateItemBase)(ADyn.GetItems(i));
                m_who = Item.Who();
                valid = m_who == 0;
                if (m_who == 1)
                {
                    valid = ((TPredicateItemBig)(Item)).ValidDescendant();
                }
                if (valid)
                {
                    D.Append(Item);
                }
            }

            if (D.Count > 0)
            {
                N = f_BasePath.CreatePathNode(AHead);
                for (int i = 0; i <= D.Count - 1; i++)
                {
                    N.AddItem((TPredicateItemBase)(D.GetItems(i)));
                }
            }
            D = null;
            return(N);
        }
示例#4
0
 public void FreeHead()
 {
     if (f_PredicateStart != null)
     {
         f_PredicateStart = null;
     }
 }
示例#5
0
        void SetPathNode(TPredicateItemBig AHead, TDynamicArray ADyn)
        {
            int mpos = -1;
            TPredicatePathNode     L;
            TPredicatePathNodeItem NI;
            TPredicatePathNodeItem FI;
            TDynamicArray          D = new TDynamicArray();
            TPredicatePathNode     N = FillPathNode(AHead, ADyn);

            if (N != null)
            {
                L = f_UsedPath.FindLikePathNode(N);
                if (L != null)
                {
                    NI = L.FindIndexFirst(ref mpos);
                    while (NI != null)
                    {
                        FI = N.FindByBlockID(NI.BlockID);
                        if (FI != null)
                        {
                            D.Append(FI.ItemBase);
                        }
                        NI = L.FindIndexNext(ref mpos);
                    }
                }
            }
            if (D.Count == ADyn.Count)
            {
                ADyn.Clear();
                SharedConst.CopyDynamicArray(D, ADyn, false);
            }
            D = null;
        }
示例#6
0
        public TPredicateItemBig NewBig(TAlternativeParserItemBig ABig)
        {
            TPredicateItemBig N = new TPredicateItemBig();

            N.Rfc    = ABig;
            N.NumAlt = ABig.NumAlt;
            return(N);
        }
示例#7
0
 public TPredicateTFSConvertor()
 {
     f_PathStyle      = 0;
     f_TryPath        = true;
     f_PredicateStart = null;
     f_NGen           = new TPredicateNumGenerator();
     f_ListEnlarge    = new List <object>();
 }
示例#8
0
        bool CheckPath(TPredicateItemBig AHead, TPredicateItemBase AItem)
        {
            TPredicatePathNode N = FillPathNode(AHead, AItem);

            if (N != null && f_UsedPath.FindLikePathNode(N) == null)
            {
                return(false);
            }
            return(true);
        }
示例#9
0
        bool CheckPath(TPredicateItemBig AHead, TDynamicArray ADyn)
        {
            TPredicatePathNode N = FillPathNode(AHead, ADyn);

            if (N != null && f_UsedPath.FindLikePathNode(N) == null)
            {
                return(false);
            }
            return(true);
        }
示例#10
0
 public void ApplyStyle(TPredicateItemBig AHead, TPredicateItemBase AItem)
 {
     if (f_PathStyle == 0)
     {
         FillPathNode(AHead, AItem);
     }
     if (f_PathStyle == 1)
     {
         f_TryPath = CheckPath(AHead, AItem);
     }
 }
示例#11
0
        void DoCopyTree(ref TPredicateItemBig ABig, ref TDynamicArray AStack)
        {
            int m_who;
            TAlternativeParserItemList ML;
            TAlternativeParserItemBase mBase;
            TAlternativeParserItemTFS  mTFS;
            TAlternativeParserItemBig  mBig;
            TPredicateItemTFE          mTFE;
            TAlternativeParserItemBig  mRfc = ABig.Rfc;

            ML = mRfc.MainList;
            for (int i = 0; i <= ML.Count - 1; i++)
            {
                mBase = ML.GetItems(i);
                m_who = mBase.Who();
                if (m_who == 0)
                {
                    mTFS = (TAlternativeParserItemTFS)(mBase);
                    TPredicateItemTFS iTfs = new TPredicateItemTFS();
                    iTfs.Assign(mTFS);
                    ABig.AddItem(iTfs);
                    for (int j = 0; j <= iTfs.TFECount - 1; j++)
                    {
                        mTFE = iTfs.GetTFEItems(j);
                        if (mTFE.RfcTFE.Big != null)
                        {
                            TPredicateItemBig iBig = NewBig(mTFE.RfcTFE.Big);
                            mTFE.Big = iBig;
                            AStack.InsertToFirst(iBig);
                        }
                    }
                }
                if (m_who == 1)
                {
                    mBig = (TAlternativeParserItemBig)(mBase);
                    TPredicateItemBig iBig = NewBig(mBig);
                    ABig.AddItem(iBig);
                    AStack.InsertToFirst(iBig);
                }
            }

            for (int i = 0; i <= mRfc.CountBig - 1; i++)
            {
                mBig = mRfc.GetItemsBig(i);
                TPredicateItemBig iBig = NewBig(mBig);
                ABig.AddItem(iBig);
                AStack.InsertToFirst(iBig);
            }
        }
示例#12
0
 public void ApplyStyle(TPredicateItemBig AHead, TDynamicArray ADyn)
 {
     if (f_PathStyle == 0)
     {
         FillPathNode(AHead, ADyn);
     }
     if (f_PathStyle == 1)
     {
         f_TryPath = CheckPath(AHead, ADyn);
     }
     if (f_PathStyle == 2)
     {
         SetPathNode(AHead, ADyn);
     }
 }
示例#13
0
        public void CopyTree(TAlternativeParserItemBig AHead)
        {
            TPredicateItemBig Big;

            FreeHead();
            f_PredicateStart = NewBig(AHead);
            TDynamicArray m_Stack = new TDynamicArray();

            Big = f_PredicateStart;
            while (Big != null)
            {
                DoCopyTree(ref Big, ref m_Stack);
                Big = (TPredicateItemBig)(m_Stack.Pop());
            }
            m_Stack = null;
        }
示例#14
0
        TPredicatePathNode FillPathNode(TPredicateItemBig AHead, TPredicateItemBase AItem)
        {
            TPredicatePathNode N = null;
            int  m_who           = AItem.Who();
            bool valid           = m_who == 0;

            if (m_who == 1)
            {
                valid = ((TPredicateItemBig)(AItem)).ValidDescendant();
            }
            if (valid)
            {
                N = f_BasePath.CreatePathNode(AHead);
                N.AddItem(AItem);
            }
            return(N);
        }
示例#15
0
        bool CheckEnlargeNum(TPredicateItemBig ABig)
        {
            TPredicateItemBig Item;

            if (ABig.Rfc.Enlarge > 0)
            {
                for (int i = 0; i <= f_ListEnlarge.Count - 1; i++)
                {
                    Item = (TPredicateItemBig)(f_ListEnlarge.ElementAt(i));
                    if ((Item.Rfc.Enlarge == ABig.Rfc.Enlarge) && (Item.Rfc.EnlargeSetNum))
                    {
                        ABig.ID = Item.ID;
                        return(true);
                    }
                }
                ABig.Rfc.EnlargeSetNum = true;
                f_ListEnlarge.Add(ABig);
            }
            return(false);
        }
示例#16
0
        TPredicateItemBig DoPrintBig(ref TPredicateItemBig ABig, ref TDynamicArray AStack)
        {
            TPredicateItemBig  Res = null;
            TPredicateItemBase m_Base;

            if (!ABig.Envelope)
            {
                if (ABig.Rfc.ParentTFE == null && ABig.Print)
                {
                    Res = ABig;
                }
                int m_cnt = ABig.Count;
                for (int i = 0; i <= m_cnt - 1; i++)
                {
                    m_Base             = ABig.GetItems(i);
                    m_Base.EnvelopeBIG = ABig;
                    CheckParseItem(ref m_Base, ref AStack);
                }
            }
            return(Res);
        }
示例#17
0
        /*        AnsiString PrintPWork(TPredicateItemPWork* APWork, TDynamicArray* AStack);
         *      AnsiString PrintBig(TPredicateItemBig* ABig, TDynamicArray* AStack);
         *      AnsiString ParseItem(TPredicateItemBase* ABase, TDynamicArray* AStack);*/

        TPredicateItemBase DoParseItem(ref TPredicateItemBase ABase, ref TDynamicArray AStack)
        {
            TPredicateItemBase Res = null;
            int m_who = ABase.Who();

            if (m_who == 1)
            {
                TPredicateItemBig m_Big = (TPredicateItemBig)(ABase);
                Res = DoPrintBig(ref m_Big, ref AStack);
            }
            if (m_who == 2)
            {
                TPredicateItemPWork m_PW = (TPredicateItemPWork)(ABase);
                Res = DoPrintPWork(ref m_PW, ref AStack);
            }
            if (m_who == 0)
            {
                Res = ABase;
            }
            return(Res);
        }
示例#18
0
 void PushBig(TPredicateItemBig ABig, ref TDynamicArray AStack)
 {
     if (ABig.Envelope)
     {
         TPredicateItemBase B = ABig.GetItems(0);
         B.EnvelopeBIG = ABig;
         int m_who = B.Who();
         if ((m_who == 2) || (m_who == 1))
         {
             AStack.InsertToFirst(B);
         }
         if (m_who == 0)
         {
             PushTFS((TPredicateItemTFS)(B), ref AStack);
         }
     }
     else
     {
         AStack.InsertToFirst(ABig);
     }
 }
示例#19
0
        TPredicateItemBase EnvelopeToBig(TPredicateItemBase ASource)
        {
            TPredicateItemTFS mTfs;
            TPredicateItemBig nBig;
            int m_who = ASource.Who();

            if (m_who == 1)
            {
                return(ASource);
            }
            if (m_who == 0)
            {
                mTfs = (TPredicateItemTFS)(ASource);
                if (mTfs.TFS.BaseWorkShape.TypeShape == 1)
                {
                    return(ASource);
                }
            }
            nBig          = new TPredicateItemBig();
            nBig.Envelope = true;
            nBig.AddItem(ASource);
            SwapNumAlt(nBig, ASource);
            return(nBig);
        }
示例#20
0
 public TPredicateItemTFE()
 {
     f_TFE    = null;
     f_Big    = null;
     f_RfcTFE = null;
 }
示例#21
0
 public void Make(TPredicateItemBase AItem, TPredicateItemBig AParent)
 {
     f_Item   = AItem;
     f_Parent = AParent;
     DoMake();
 }
示例#22
0
 public TGraphTFEConvertorItem()
 {
     f_Out    = "";
     f_Item   = null;
     f_Parent = null;
 }
示例#23
0
        void DoProcessItem(TPredicateItemBig AHead, TDynamicArray AStack)
        {
            int m_type, m_cnt, m_idx;
            TPredicateItemBase  m_Base;
            TPredicateItemBase  m_BaseItem1, m_BaseItem2;
            TPredicateItemPWork m_PWork, m_PW;
            TPredicateItemBig   m_Big;
            TPredicateItemTFS   m_Tfs;
            TPredicateItemTFE   m_Tfe;
            TDynamicArray       m_D     = new TDynamicArray();
            TDynamicArray       m_DTail = new TDynamicArray();
            TDynamicArray       m_DLN   = new TDynamicArray();

            m_cnt = AHead.Count;
            if (m_cnt == 1)
            {
                m_Base = AHead.GetItems(0);
                DoProcessItemTFS(m_Base, AStack);
                if (m_Base.Who() == 1)
                {
                    ((TPredicateItemBig)(m_Base)).Print = true;
                }

                ApplyStyle(AHead, m_Base);
            }
            if (m_cnt > 1)
            {
                for (int i = 0; i <= m_cnt - 1; i++)
                {
                    m_Base = AHead.GetItems(i);
                    m_type = m_Base.Who();
                    if (m_type == 1)
                    {
                        m_Big = (TPredicateItemBig)(m_Base);
                        if (m_Big.NumAlt > 0 || m_Big.Rfc.Cross)
                        {
                            m_DTail.Append(m_Big);
                            m_Big.Print = true;
                        }
                        else
                        {
                            m_DLN.Append(m_Base);
                            // m_Big.Print = m_Big.Rfc.CrossMain;
                        }
                    }
                    else
                    {
                        m_DLN.Append(m_Base);
                    }
                }
                if (m_DLN.Count == 1)
                {
                    m_Base = (TPredicateItemBase)(m_DLN.GetItems(0));
                    DoProcessItemTFS(m_Base, AStack);
                    ApplyStyle(AHead, m_Base);
                }
                else
                if (m_DLN.Count > 1)
                {
                    ApplyStyle(AHead, m_DLN);
                    m_BaseItem1 = (TPredicateItemBase)(m_DLN.GetItems(0));
                    m_BaseItem2 = (TPredicateItemBase)(m_DLN.GetItems(1));
                    DoProcessItemTFS(m_BaseItem1, AStack);
                    DoProcessItemTFS(m_BaseItem2, AStack);
                    for (int i = 2; i <= m_DLN.Count - 1; i++)
                    {
                        m_D.Append(m_DLN.GetItems(i));
                    }

                    AHead.DeleteItemToList(m_BaseItem1);
                    AHead.DeleteItemToList(m_BaseItem2);


                    m_BaseItem1 = EnvelopeToBig(m_BaseItem1);
                    m_BaseItem2 = EnvelopeToBig(m_BaseItem2);

                    m_PWork       = new TPredicateItemPWork();
                    m_PWork.Item1 = m_BaseItem1;
                    m_PWork.Item2 = m_BaseItem2;
                    SwapNumAlt(m_PWork, m_BaseItem1);



                    while (m_D.Count >= 1)
                    {
                        m_Big = (TPredicateItemBig)(EnvelopeToBig(m_PWork));

                        m_BaseItem1 = m_Big;
                        m_BaseItem2 = (TPredicateItemBase)(m_D.GetItems(0));
                        DoProcessItemTFS(m_BaseItem2, AStack);
                        AHead.DeleteItemToList(m_BaseItem2);

                        m_PW = new TPredicateItemPWork();
                        //m_PW.Envelope = true;
                        m_PW.Item1 = m_BaseItem1;
                        m_PW.Item2 = EnvelopeToBig(m_BaseItem2);
                        SwapNumAlt(m_PW, m_Big);
                        m_D.Delete(m_BaseItem2);
                        m_PWork = m_PW;
                    }

                    AHead.AddItem(m_PWork);
                }

                for (int i = 0; i <= m_DTail.Count - 1; i++)
                {
                    m_Base = (TPredicateItemBase)(m_DTail.GetItems(i));
                    AStack.InsertToFirst(m_Base);
                }

                m_DTail = null;
                m_DLN   = null;
                m_D     = null;
            }
        }
示例#24
0
        void DoSetIDItem(TPredicateItemBig AHead, TDynamicArray AStack)
        {
            int m_who;
            TPredicateItemBase  m_Base;
            TPredicateItemPWork m_PW;
            int m_cnt = AHead.Count;

            for (int i = 0; i <= m_cnt - 1; i++)
            {
                m_Base = AHead.GetItems(i);
                m_who  = m_Base.Who();
                if (m_who == 1)
                {
                    TPredicateItemBig mBig = (TPredicateItemBig)(m_Base);
                    if (CheckEnlargeNum(mBig))
                    {
                        return;
                    }
                    m_Base.ID = f_NGen.NextLowNum();
                }
                if (m_who == 2)
                {
                    m_PW = (TPredicateItemPWork)(m_Base);

                    m_who = m_PW.Item1.Who();
                    if (m_who == 1)
                    {
                        TPredicateItemBig mBig = (TPredicateItemBig)(m_PW.Item1);
                        if (mBig.Rfc != null && mBig.Rfc.Enlarge > 0)
                        {
                            if (!CheckEnlargeNum(mBig))
                            {
                                m_PW.Item1.ID = f_NGen.NextLowNum();
                            }
                        }
                        else
                        {
                            m_PW.Item1.ID = f_NGen.NextLowNum();
                        }
                    }

                    m_who = m_PW.Item2.Who();
                    if (m_who == 1)
                    {
                        TPredicateItemBig mBig = (TPredicateItemBig)(m_PW.Item2);
                        if (mBig.Rfc != null && mBig.Rfc.Enlarge > 0)
                        {
                            if (!CheckEnlargeNum(mBig))
                            {
                                m_PW.Item2.ID = f_NGen.NextLowNum();
                            }
                        }
                        else
                        {
                            m_PW.Item2.ID = f_NGen.NextLowNum();
                        }
                    }


                    //        m_PW.Item2.ID = f_NGen.NextLowNum();
                }
                DoSetIDItemTFS(m_Base, AStack);
            }
        }