public override void Convert(iStateCreater <T> creater, T beginState, ref T endState, NDFA <T, char> ndfa) { T choiceOneBeginState = creater.Next(); T choiceTwoBeginState = creater.Next(); T choiceOneEndState = default(T); T choiceTwoEndState = default(T); //Create empty epsilon from begin to begin of the choices ndfa.AddTransition(beginState, choiceOneBeginState, ndfa.Epsilon); ndfa.AddTransition(beginState, choiceTwoBeginState, ndfa.Epsilon); choiceOne.Convert(creater, choiceOneBeginState, ref choiceOneEndState, ndfa); choiceTwo.Convert(creater, choiceTwoBeginState, ref choiceTwoEndState, ndfa); //Create empty epsilon from end of the coices to end state endState = creater.Next(); ndfa.AddTransition(choiceOneEndState, endState, ndfa.Epsilon); ndfa.AddTransition(choiceTwoEndState, endState, ndfa.Epsilon); }
public override void Convert(iStateCreater <T> creater, T beginState, ref T endState, NDFA <T, char> ndfa) { endState = creater.Next(); if (loopMin == 0) { ndfa.AddTransition(beginState, endState, ndfa.Epsilon); } T beginLoopState = creater.Next(); T endLoopState = default(T); this.block.Convert(creater, beginLoopState, ref endLoopState, ndfa); //Epsilon from start to start loop ndfa.AddTransition(beginState, beginLoopState, ndfa.Epsilon); //Epsilon from end loop to start loop ndfa.AddTransition(endLoopState, beginLoopState, ndfa.Epsilon); //Epsilon from end loop to end state ndfa.AddTransition(endLoopState, endState, ndfa.Epsilon); }
public override void Convert(iStateCreater <T> creater, T beginState, ref T endState, NDFA <T, char> grammar) { endState = creater.Next(); grammar.AddTransition(beginState, endState, terminal); }