Пример #1
0
 public NFAGraph(MatchFactorWithOp mtch)
 {
     InstantiateFromMatchFactorOp(mtch);
 }
Пример #2
0
 private void InstantiateFromMatchFactorOp(MatchFactorWithOp mop)
 {
     var mf = new NFAGraph(mop.Factor);
     CopyIntoWithTerminals(mf);
     switch (mop.Op.Type)
     {
         case UnaryOperatorType.None:
             break;
         case UnaryOperatorType.Optional:
             var elink1 = new NFALink();
             elink1.IsEmpty = true;
             elink1.Target = _finishState.Single();
             _adjList[_startState].Add(elink1);
             break;
         case UnaryOperatorType.OneMany:
             var elink2 = new NFALink();
             elink2.IsEmpty = true;
             elink2.Target = _startState;
             _adjList[_finishState.Single()].Add(elink2);
             break;
         case UnaryOperatorType.NoneMany:
             var newend = NewState();
             var blink = new NFALink();
             var flink = new NFALink();
             blink.IsEmpty = true;
             flink.IsEmpty = true;
             blink.Target = _startState;
             flink.Target = newend;
             _adjList[_finishState.Single()].Add(blink);
             _adjList[_startState].Add(flink);
             _finishState = new HashSet<NFAState>{newend};
             break;
     }
 }