-
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 indexed grammars #15
base: rework_cfg
Are you sure you want to change the base?
Conversation
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.
All docstrings should be updated too.
@@ -41,7 +41,7 @@ def test_production_rules(self): | |||
""" Tests the production rules """ | |||
produ = ProductionRule("S", "C", "end") |
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 production
?
pyformlang/indexed_grammar/utils.py
Outdated
from typing import Callable, List, Set, Iterable, Any | ||
|
||
|
||
def exists(list_elements: List[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.
Is it any(map(predicate, iterable))
? As I know, map
returns enumerator, not list, so this version should be more or less optimal.
|
||
@property | ||
def right_terms(self) -> Tuple[Any, Any]: | ||
def right_terms(self) -> List[CFGObject]: | ||
"""Gives the non-terminals on the right of the rule | ||
|
||
Returns | ||
--------- | ||
right_terms : iterable of 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.
List of CFGObjects ?
is_duplication : bool | ||
Whether the rule is a duplication rule or not | ||
--------- | ||
left_term : 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.
Is it Any
actually?
|
||
@property | ||
def non_terminals(self) -> Iterable[Any]: | ||
def non_terminals(self) -> Set[Variable]: | ||
"""Gets the non-terminals used in the rule | ||
|
||
non_terminals : iterable of 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.
Set?
def left_term(self) -> Variable: | ||
"""Gets the symbol on the left of the rule | ||
|
||
left : 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.
Any?
|
||
@property | ||
def states(self): | ||
def states(self) -> Set[State]: | ||
""" Get the states of the FST | ||
|
||
Returns |
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.
of State
548fc06
to
32963bd
Compare
Rework the remaining modules:
fst
andindexed_grammar
. Use existing object representations for better typing, remove import cycles by refactoring the intersection methods. Add pyright type checker to requirements, update CI config by adding type checking jobs. Also split CI into different workflows to make the configuration clearer.Changes by module:
indexed_grammar
:IndexedGrammar
fromFST
.FST
explicitly.utils
file to contain nontrivial indexed grammar utility.fst
:FST
by using finite automata object representations.FST
to make it similar to the other classes.TransitionFunction
class.utils
file.