private static void AddTransitionPushingOne(Transition <A, S> transition, SDA <A, TripleStackSymbol <S> > sda, PDA <A, S> dpda, Dictionary <string, TripleStackSymbol <S> > stackSymbols) { foreach (var r in dpda.States) { var stackSymbolIn = stackSymbols[TripleStackSymbol <S> .GetKey(transition.Origin.Id, transition.StackSymbolIn, r.Key)]; var stackSymbolsOut = new TripleStackSymbol <S>[] { stackSymbols[TripleStackSymbol <S> .GetKey(transition.Target.Id, transition.StackSymbolsWritten.First(), r.Key)] }; sda.AddTransition(transition.SymbolIn.GetSymbol(), stackSymbolIn, stackSymbolsOut); } }
private static IEnumerable <TripleStackSymbol <S> > RemoveEpsilonSymbolsFromRightHandSide(SDA <A, TripleStackSymbol <S> > sda, PDA <A, S> dpda, Dictionary <string, TripleStackSymbol <S> > stackSymbols) { var epsilonSymbols = new List <TripleStackSymbol <S> >(); var transitions = dpda.States.SelectMany(s => s.Value.Transitions).ToList(); foreach (var t in transitions.Where(t => t.SymbolIn.IsEmpty())) { var epsilonSymbol = stackSymbols[TripleStackSymbol <S> .GetKey(t.Origin.Id, t.StackSymbolIn, t.Target.Id)]; epsilonSymbols.Add(epsilonSymbol); foreach (var sdaTransition in sda.Transitions.Where(sdaTransition => sdaTransition.StackSymbolsWritten.Contains(epsilonSymbol))) { sdaTransition.RemoveEpsilonSymbol(epsilonSymbol); } } return(epsilonSymbols); }
private static void AddTransitionPushingNone(Transition <A, S> transition, SDA <A, TripleStackSymbol <S> > sda, Dictionary <string, TripleStackSymbol <S> > stackSymbols) { var stackSymbolIn = stackSymbols[TripleStackSymbol <S> .GetKey(transition.Origin.Id, transition.StackSymbolIn, transition.Target.Id)]; sda.AddTransition(transition.SymbolIn.GetSymbol(), stackSymbolIn); }