Example #1
0
        private static SimulationPath <A, char> RunSimulationWithCFGForFinalState(PDA <A, char> pda, A[] word, CancellationToken token)
        {
            Assertion.Assert(pda.AcceptanceCondition.IsFinalState(), "the pda has not final state as acceptance condition");

            var pdaWithEmptyStack = PDATransformer <A, char> .ToPDAWithEmptyStack(pda);

            var path = RunSimulationWithCFGForEmptyStack(pdaWithEmptyStack, word, token);

            return(ConvertEmptyStackSimulationPathBackToFinalState(path, pda));
        }
 internal PDARunnerWithCFG(PDA <A, S> pda, CancellationToken token)
 {
     if (pda.AcceptanceCondition.IsEmptyStack())
     {
         AddCFGOfPDA(pda, AcceptanceCondition.EmptyStack.GetId(), token);
     }
     if (pda.AcceptanceCondition.IsFinalState())
     {
         AddCFGOfPDA(PDATransformer <A, S> .ToPDAWithEmptyStack(pda), AcceptanceCondition.FinalState.GetId(), token);
     }
 }