Loading lib/grammars_cfg.py +9 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,8 @@ def zip_fill(seqa: Iterable[TA], seqb: Iterable[TB], sentinel: bool = False) \ class ChangeTracker: __slots__ = ["_changed"] def __init__(self): self._changed = True Loading @@ -135,6 +137,8 @@ class CFG: Word = Tuple[Terminal, ...] Rules = Dict[Nonterminal, Set[Production]] __slots__ = ["nonterminals", "terminals", "rules", "init"] def __init__(self, nonterminals: Set[Nonterminal], terminals: Set[Terminal], rules: CFG.Rules, Loading Loading @@ -651,6 +655,8 @@ class WordGenerator: CountMap = Dict[Nonterminal, int] ProdCountMap = Dict[CFG.Production, int] __slots__ = ["cfg", "_seen", "_stack", "_cur_lenght", "_next_length", "last", "counts", "prod_counts"] def __init__(self, cfg: CFG): self.cfg = cfg.proper() self._seen: Set[CFG.Symbols] = set() Loading Loading @@ -832,6 +838,9 @@ class WordGenerator: class CachedCYK: __slots__ = ["cfg", "cache"] def __init__(self, cfg: CFG): self.cfg = cfg.cnf() self.cache: Dict[CFG.Word, Set[Nonterminal]] = dict() Loading Loading
lib/grammars_cfg.py +9 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,8 @@ def zip_fill(seqa: Iterable[TA], seqb: Iterable[TB], sentinel: bool = False) \ class ChangeTracker: __slots__ = ["_changed"] def __init__(self): self._changed = True Loading @@ -135,6 +137,8 @@ class CFG: Word = Tuple[Terminal, ...] Rules = Dict[Nonterminal, Set[Production]] __slots__ = ["nonterminals", "terminals", "rules", "init"] def __init__(self, nonterminals: Set[Nonterminal], terminals: Set[Terminal], rules: CFG.Rules, Loading Loading @@ -651,6 +655,8 @@ class WordGenerator: CountMap = Dict[Nonterminal, int] ProdCountMap = Dict[CFG.Production, int] __slots__ = ["cfg", "_seen", "_stack", "_cur_lenght", "_next_length", "last", "counts", "prod_counts"] def __init__(self, cfg: CFG): self.cfg = cfg.proper() self._seen: Set[CFG.Symbols] = set() Loading Loading @@ -832,6 +838,9 @@ class WordGenerator: class CachedCYK: __slots__ = ["cfg", "cache"] def __init__(self, cfg: CFG): self.cfg = cfg.cnf() self.cache: Dict[CFG.Word, Set[Nonterminal]] = dict() Loading