-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
69 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,23 @@ | ||
#!/usr/bin/env python3 | ||
"""Classes and methods for working with PDA configurations.""" | ||
|
||
from typing import NamedTuple | ||
from dataclasses import dataclass | ||
|
||
from automata.base.automaton import AutomatonStateT | ||
from automata.pda.stack import PDAStack | ||
|
||
|
||
class PDAConfiguration(NamedTuple): | ||
@dataclass(frozen=True) | ||
class PDAConfiguration: | ||
""" | ||
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. | ||
""" | ||
|
||
__slots__ = ("state", "remaining_input", "stack") | ||
|
||
state: AutomatonStateT | ||
remaining_input: str | ||
stack: PDAStack | ||
|
||
def __repr__(self) -> str: | ||
"""Return a string representation of the configuration.""" | ||
return "{}('{}', '{}', {})".format( | ||
self.__class__.__name__, self.state, self.remaining_input, self.stack | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters