def __init__(self, grammar):
        # type: (Grammar) -> None
        """
        :param grammar: Grammar to work with. Can be modified.
        """
        self._grammar = grammar
        self._items = dict()
        for term in grammar.terminals:
            created_nonterm = type("ChomskyTerm[" + str(term) + "]",
                                   (ChomskyTermNonterminal,),
                                   ChomskyTermNonterminal.__dict__.copy())  # type: Type[ChomskyTermNonterminal]
            created_nonterm.for_term = term
            created_rule = type("ChomskyTerm[" + str(term) + "]",
                                (ChomskyTermRule,),
                                ChomskyTermRule.__dict__.copy())  # type: Type[ChomskyTermRule]
            created_rule.rule = ([created_nonterm], [term])
            self._items[term] = Container(term, created_nonterm, created_rule)
def __init__ ( self , grammar ) : self . _grammar = grammar self . _items = dict ( ) for term in grammar . terminals : created_nonterm = type ( "ChomskyTerm[" + str ( term ) + "]" , ( ChomskyTermNonterminal , ) , ChomskyTermNonterminal . __dict__ . copy ( ) ) created_nonterm . for_term = term created_rule = type ( "ChomskyTerm[" + str ( term ) + "]" , ( ChomskyTermRule , ) , ChomskyTermRule . __dict__ . copy ( ) ) created_rule . rule = ( [ created_nonterm ] , [ term ] ) self . _items [ term ] = Container ( term , created_nonterm , created_rule )
:param grammar: Grammar to work with. Can be modified.