class_docstr: Compiles a grammar. This will take the parse tree of a regular expression
  and compile the grammar.
  
  :param root_node: :class~`.regex_parser.Node` instance.
  :param escape_funcs: `dict` mapping variable names to escape callables.
  :param unescape_funcs: `dict` mapping variable names to unescape callables.
class_docstr_tok: ["Compiles","a","grammar",".","This","will","take","the","parse","tree","of","a","regular","expression","and","compile","the","grammar",".",":","param","root_node",":",":","class~","`",".regex_parser.Node","`","instance",".",":","param","escape_funcs",":","`","dict","`","mapping","variable","names","to","escape","callables",".",":","param","unescape_funcs",":","`","dict","`","mapping","variable","names","to","unescape","callables","."]
docstr: Do a partial match of the string with the grammar. The returned
  :class:`Match` instance can contain multiple representations of the
  match. This will never return `None`. If it doesn't match at all, the "trailing input"
  part will capture all of the input.
  
  :param string: The input string.
docstr_tok: ["Do","a","partial","match","of","the","string","with","the","grammar",".","The","returned",":","class",":","`","Match","`","instance","can","contain","multiple","representations","of","the","match",".","This","will","never","return","`","None","`",".","If","it","does","n't","match","at","all",",","the","``","trailing","input","''","part","will","capture","all","of","the","input",".",":","param","string",":","The","input","string","."]
code: def match_prefix(self, string: str) -> Match | None:
      """
      Do a partial match of the string with the grammar. The returned
      :class:`Match` instance can contain multiple representations of the
      match. This will never return `None`. If it doesn't match at all, the "trailing input"
      part will capture all of the input.
  
      :param string: The input string.
      """
      # First try to match using `_re_prefix`. If nothing is found, use the patterns that
      # also accept trailing characters.
      for patterns in [
          self._re_prefix,
          self._re_prefix_with_trailing_input,
      ]:
          matches = [(r, r.match(string)) for r in patterns]
          matches2 = [(r, m) for r, m in matches if m]
  
          if matches2 != []:
              return Match(
                  string,
                  matches2,
                  self._group_names_to_nodes,
                  self.unescape_funcs,
              )
  
      return None
  
imports: from __future__ import annotations
  import re
  from typing import Callable, Dict, Iterable, Iterator, Pattern
  from typing import Match
  from .regex_parser import AnyNode, Lookahead, Node, NodeSequence, Regex, Repeat, Variable, parse_regex, tokenize_regex
label_desc: Use image node_id 7 for calling the _CompiledGrammar obj's underlying member method code with example usage: obj.match_prefix(string) and returns: None, Match