def _read_grammar(self, grammar, root_label, trace):
        rules = []
        lhs = None
        for line in grammar.split('\n'):
            line = line.strip()

            # New stage begins if there's an unescaped ':'
            m = re.match('(?P<nonterminal>(\\.|[^:])*)(:(?P<rule>.*))', line)
            if m:
                # Record the stage that we just completed.
                self._add_stage(rules, lhs, root_label, trace)
                # Start a new stage.
                lhs = m.group('nonterminal').strip()
                rules = []
                line = m.group('rule').strip()

            # Skip blank & comment-only lines
            if line=='' or line.startswith('#'): continue

            # Add the rule
            rules.append(RegexpChunkRule.fromstring(line))

        # Record the final stage
        self._add_stage(rules, lhs, root_label, trace)
Helper function for __init__: read the grammar if it is a
dataset/ETHPy150Open nltk/nltk/nltk/chunk/regexp.py/RegexpParser._read_grammar