# Path: automata/pda/configuration.py
# class PDAConfiguration(collections.namedtuple(
#     'PDAConfiguration',
#     ['state', 'remaining_input', 'stack']
# )):
#     """
#     A configuration is a triple of current state, remaining input and stack.
# 
#     It represents the complete runtime state of a PDA.
#     It is hashable and immutable.
#     """
# 
#     def __repr__(self):
#         """Return a string representation of the configuration."""
#         return '{}(\'{}\', \'{}\', {})'.format(
#             self.__class__.__name__,
#             self.state,
#             self.remaining_input,
#             self.stack
#         )
# 
# Path: automata/pda/stack.py
# class PDAStack(collections.namedtuple('PDAStack', ['stack'])):
#     """A PDA stack."""
# 
#     def __new__(cls, *elements):
#         """Create the new PDA stack."""
#         if len(elements) == 1:
#             stack = tuple(elements[0])
#         else:
#             stack = elements
#         return super(PDAStack, cls).__new__(cls, stack)
# 
#     def top(self):
#         """Return the symbol at the top of the stack."""
#         if self.stack:
#             return self.stack[-1]
#         else:
#             return ''
# 
#     def pop(self):
#         """
#         Pop the stack top from the stack.
# 
#         Return a new PDAStack with the new content.
#         """
#         stack_contents = list(self.stack)
#         stack_contents.pop()
#         return self.__class__(stack_contents)
# 
#     def replace(self, symbols):
#         """
#         Replace the top of the stack with the given symbols.
# 
#         Return a new PDAStack with the new content.
#         The first symbol in the given sequence becomes the new stack top.
#         """
#         stack_contents = list(self.stack)
#         stack_contents.pop()
#         stack_contents.extend(reversed(symbols))
#         return self.__class__(stack_contents)
# 
#     def __len__(self):
#         """Return the number of symbols on the stack."""
#         return len(self.stack)
# 
#     def __iter__(self):
#         """Return an interator for the stack."""
#         return iter(self.stack)
# 
#     def __repr__(self):
#         """Return a string representation of the stack."""
#         return '{}{}'.format(self.__class__.__name__, self.stack)


import copy
import automata.base.exceptions as exceptions
import automata.pda.exceptions as pda_exceptions
import automata.pda.pda as pda
from automata.pda.configuration import PDAConfiguration
from automata.pda.stack import PDAStack
                    old_config.state,
                    old_config.remaining_input[0],
                    old_config.stack.top()
                )
            )
        if len(transitions) > 1:
            raise pda_exceptions.NondeterminismError(
                'The automaton entered a configuration for which more'
                'than one transition is defined ({}, {}'.format(
                    old_config.state,
                    old_config.stack.top()
                )
            )
        input_symbol, new_state, new_stack_top = transitions.pop()
        remaining_input = old_config.remaining_input
        if input_symbol:
            remaining_input = remaining_input[1:]
        new_config = PDAConfiguration(
            new_state,
            remaining_input,
            self._replace_stack_top(old_config.stack, new_stack_top)
        )
        return new_config

    def read_input_stepwise(self, input_str):
        """
        Check if the given string is accepted by this DPDA.

        Yield the DPDA's current configuration at each step.
        """

# Path: automata/pda/configuration.py
# class PDAConfiguration(collections.namedtuple(
#     'PDAConfiguration',
#     ['state', 'remaining_input', 'stack']
# )):
#     """
#     A configuration is a triple of current state, remaining input and stack.
# 
#     It represents the complete runtime state of a PDA.
#     It is hashable and immutable.
#     """
# 
#     def __repr__(self):
#         """Return a string representation of the configuration."""
#         return '{}(\'{}\', \'{}\', {})'.format(
#             self.__class__.__name__,
#             self.state,
#             self.remaining_input,
#             self.stack
#         )
# 
# Path: automata/pda/stack.py
# class PDAStack(collections.namedtuple('PDAStack', ['stack'])):
#     """A PDA stack."""
# 
#     def __new__(cls, *elements):
#         """Create the new PDA stack."""
#         if len(elements) == 1:
#             stack = tuple(elements[0])
#         else:
#             stack = elements
#         return super(PDAStack, cls).__new__(cls, stack)
# 
#     def top(self):
#         """Return the symbol at the top of the stack."""
#         if self.stack:
#             return self.stack[-1]
#         else:
#             return ''
# 
#     def pop(self):
#         """
#         Pop the stack top from the stack.
# 
#         Return a new PDAStack with the new content.
#         """
#         stack_contents = list(self.stack)
#         stack_contents.pop()
#         return self.__class__(stack_contents)
# 
#     def replace(self, symbols):
#         """
#         Replace the top of the stack with the given symbols.
# 
#         Return a new PDAStack with the new content.
#         The first symbol in the given sequence becomes the new stack top.
#         """
#         stack_contents = list(self.stack)
#         stack_contents.pop()
#         stack_contents.extend(reversed(symbols))
#         return self.__class__(stack_contents)
# 
#     def __len__(self):
#         """Return the number of symbols on the stack."""
#         return len(self.stack)
# 
#     def __iter__(self):
#         """Return an interator for the stack."""
#         return iter(self.stack)
# 
#     def __repr__(self):
#         """Return a string representation of the stack."""
#         return '{}{}'.format(self.__class__.__name__, self.stack)


# Path: automata/pda/dpda.py
import copy
import automata.base.exceptions as exceptions
import automata.pda.exceptions as pda_exceptions
import automata.pda.pda as pda
from automata.pda.configuration import PDAConfiguration
from automata.pda.stack import PDAStack

                    old_config.state,
                    old_config.remaining_input[0],
                    old_config.stack.top()
                )
            )
        if len(transitions) > 1:
            raise pda_exceptions.NondeterminismError(
                'The automaton entered a configuration for which more'
                'than one transition is defined ({}, {}'.format(
                    old_config.state,
                    old_config.stack.top()
                )
            )
        input_symbol, new_state, new_stack_top = transitions.pop()
        remaining_input = old_config.remaining_input
        if input_symbol:
            remaining_input = remaining_input[1:]
        new_config = PDAConfiguration(
            new_state,
            remaining_input,
            self._replace_stack_top(old_config.stack, new_stack_top)
        )
        return new_config

    def read_input_stepwise(self, input_str):
        """
        Check if the given string is accepted by this DPDA.

        Yield the DPDA's current configuration at each step.
        """

        current_configuration = PDAConfiguration(