-
Notifications
You must be signed in to change notification settings - Fork 0
Rework cfg #14
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
base: rework_architecture
Are you sure you want to change the base?
Rework cfg #14
Conversation
|
Significant architecture changes are:
|
| 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?
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.
Type inconsistency.
| 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.
Types.
| 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.
Types.
| """ A state in a finite automaton | ||
| Parameters | ||
| ---------- |
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.
Types.
94af59a to
1d1e8f1
Compare
…ration, add missing pda methods
…import cycles, correct types in get_words
…ions, add base epsilon class
Here we plan to rework
cfgand 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.FormalObjectclass.StackSymbolfromSymbolandEpsilonfromStackSymbolto handle some type mismatches.cfg:to_pdamethod fromCFGclass, addfrom_cfgmethod for pda instead.FormalGrammarabstract class to handle import cycles in cfg module, generalize some methods and properties.add_productionmethod for grammars, add methods for changing start symbol of the grammar.pdamodule.fcfg:from_textmethod for FCFG using generics in theFormalGrammarclass.add_productionby converting the given rule toFeatureProductionclass, use that conversion in the constructor.pda:cfgmodule.utilsfile.