'Create a new chunk parser, from the given start state
and set of chunk patterns.
:param grammar: The grammar, or a list of RegexpChunkParser objects
:type grammar: str or list(RegexpChunkParser)
:param root_label: The top node of the tree being created
:type root_label: str or Nonterminal
:param loop: The number of times to run through the patterns
:type loop: int
:type trace: int
:param trace: The level of tracing that should be used when
parsing a text.  ``0`` will generate no tracing output;
``1`` will generate normal tracing output; and ``2`` or
higher will generate verbose tracing output.'

def __init__(self, grammar, root_label=u'S', loop=1, trace=0):

    self._trace = trace
    self._stages = []
    self._grammar = grammar
    self._loop = loop
    if isinstance(grammar, string_types):
        self._read_grammar(grammar, root_label, trace)
    else:
        type_err = u'Expected    string    or    list    of    RegexpChunkParsers    for    the    grammar.'
        try:
            grammar = list(grammar)
        except:
            raise TypeError(type_err)
        for elt in grammar:
            if (not isinstance(elt, RegexpChunkParser)):
                raise TypeError(type_err)
        self._stages = grammar
