Beispiel #1
0
 public bool HasSameTopMostSymbolsLike(CurrentStack <S> otherStack, int number)
 {
     if (StackSymbols.Count() < number || otherStack.StackSymbols.Count() < number)
     {
         return(false);
     }
     return(StackSymbols.Take(number).SequenceEqual(otherStack.StackSymbols.Take(number)));
 }
Beispiel #2
0
 public static CurrentStack <S> ApplyTransitionToStack <A>(Transition <A, S> transition, CurrentStack <S> stackBefore) where A : IEquatable <A>
 {
     Assertion.Assert(!stackBefore.IsEmpty(), "a transition cannot be applied to an empty stack");
     Assertion.Assert(transition.StackSymbolIn.Equals(stackBefore.StackSymbols.First()), "the input-stack-symbol of the transition has to be the same as the first one of current stack");
     return(new CurrentStack <S>(transition.StackSymbolsWritten.Concat(stackBefore.StackSymbols.Skip(1)).ToList()));
 }
Beispiel #3
0
 public static Configuration <A, S> ApplyTransitionToConfiguration(Transition <A, S> transition, Configuration <A, S> configurationBefore)
 {
     return(new Configuration <A, S>(transition.Target,
                                     Word <A> .ApplyTransitionToWord <S>(transition, configurationBefore.RemainingWord),
                                     CurrentStack <S> .ApplyTransitionToStack <A>(transition, configurationBefore.Stack)));
 }
Beispiel #4
0
 public Configuration(State <A, S> state, Word <A> remainingWord, CurrentStack <S> stack)
 {
     State         = state;
     RemainingWord = remainingWord;
     Stack         = stack;
 }