Beispiel #1
0
 private void FillAction(State tempState, ExtendRule tempER)
 {
     if (tempER.PointRight.Count == 0)
     {
         if (tempER.leftRule == OG.startSymbol)
         {
             ActionNode node = new ActionNode(ActionChoice.accept);
             tempState.myAction.Add("#", node);
             return;
         }
         else
         {
             ActionNode node = new ActionNode(ActionChoice.reduct, tempER.OriginRule);
             foreach (string tmp in OG.tSymbol)
             {
                 tempState.myAction.Add(tmp, node);
             }
             return;
         }
     }
     else
     {
         if (OG.StrToSymbol(tempER.PointRight[0]).kind == symKind.term)
         {
             int next = -1;
             if (tempState.DFAedge.TryGetValue(tempER.PointRight[0], out next))
             {
                 ActionNode node = new ActionNode(ActionChoice.addin, next);
                 tempState.myAction.Add(tempER.PointRight[0], node);
             }
         }
     }
 }
Beispiel #2
0
        private void SameStateRule(int erNum, List <ExtendRule> stateER)
        {
            ExtendRule er        = ERSet[erNum];
            int        nextIndex = -1;

            stateER.Add(er);
            if (er.PointRight.Count != 0)
            {
                if (OG.StrToSymbol(er.PointRight[0]).kind == symKind.notTerm)
                {
                    do
                    {
                        nextIndex = FindNext(er.PointRight[0], nextIndex + 1);
                        if (nextIndex != -1)
                        {
                            SameStateRule(nextIndex, stateER);
                        }
                    } while (nextIndex != -1);
                }
            }
        }