-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework cfg #14
base: rework_architecture
Are you sure you want to change the base?
Rework cfg #14
Conversation
Significant architecture changes are:
|
|
||
fa_type = TypeVar("fa_type", bound="FiniteAutomaton") | ||
AutomatonT = TypeVar("AutomatonT", bound="FiniteAutomaton") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T
stands for Type
? If so, let's use full word Type
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just FiniteAutomaton
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T
is commonly used with generic types. Here we use generics to define copying for all of existing automata types
@@ -100,7 +115,7 @@ def _get_parse_tree_sub(self, word, current_expansion, left=True): | |||
return True | |||
return False | |||
|
|||
def is_parsable(self, word, left=True): | |||
def is_parsable(self, word: Iterable[Hashable], left: bool = True) -> bool: | |||
""" | |||
Whether a word is parsable or not | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update docstring
productions: Iterable[FeatureProduction] = None): | ||
variables: AbstractSet[Hashable] = None, | ||
terminals: AbstractSet[Hashable] = None, | ||
start_symbol: Hashable = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What the problem to make start_symbol
has type Variable
? Current type looks not pretty specific.
from ..formal_object import FormalObject | ||
|
||
|
||
class Terminal(CFGObject): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it be unified over all regexps, grammars, etc? Terminal is a common thing for all language-related formalisms.
|
||
Parameters | ||
----------- | ||
value : any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can variable be unified over all cfg-related formalisms?
|
||
Parameters | ||
---------- | ||
given : any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hashable?
…ration, add missing pda methods
…import cycles, correct types in get_words
…ions, add base epsilon class
Here we plan to rework
cfg
and some related modules, removing cycles and adding type annotations. Modules we should consider are:cfg
;pda
;fcfg
.Changes by module:
objects
:State
,Terminal
, etc.) to a separate module to improve the structure of the project and handle some design issues.FormalObject
class.StackSymbol
fromSymbol
andEpsilon
fromStackSymbol
to handle some type mismatches.cfg
:to_pda
method fromCFG
class, addfrom_cfg
method for pda instead.FormalGrammar
abstract class to handle import cycles in cfg module, generalize some methods and properties.add_production
method for grammars, add methods for changing start symbol of the grammar.pda
module.fcfg
:from_text
method for FCFG using generics in theFormalGrammar
class.add_production
by converting the given rule toFeatureProduction
class, use that conversion in the constructor.pda
:cfg
module.utils
file.