'Copy the grammar.'

def copy(self):

    new = self.__class__()
    for dict_attr in ('symbol2number', 'number2symbol', 'dfas', 'keywords', 'tokens', 'symbol2label'):
        setattr(new, dict_attr, getattr(self, dict_attr).copy())
    new.labels = self.labels[:]
    new.states = self.states[:]
    new.start = self.start
    return new
