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.
code: def __init__(self, root_node, escape_funcs=None, unescape_funcs=None):
      self.root_node = root_node
      self.escape_funcs = escape_funcs or {}
      self.unescape_funcs = unescape_funcs or {}
  
      #: Dictionary that will map the redex names to Node instances.
      self._group_names_to_nodes = (
          {}
      )  # Maps regex group names to varnames.
      counter = [0]
  
      def create_group_func(node):
          name = "n%s" % counter[0]
          self._group_names_to_nodes[name] = node.varname
          counter[0] += 1
          return name
  
      # Compile regex strings.
      self._re_pattern = "^%s$" % self._transform(
          root_node, create_group_func
      )
      self._re_prefix_patterns = list(
          self._transform_prefix(root_node, create_group_func)
      )
  
      # Compile the regex itself.
      flags = (
          re.DOTALL
      )  # Note that we don't need re.MULTILINE! (^ and $
      # still represent the start and end of input text.)
      self._re = re.compile(self._re_pattern, flags)
      self._re_prefix = [
          re.compile(t, flags) for t in self._re_prefix_patterns
      ]
  
      # We compile one more set of regexes, similar to `_re_prefix`, but accept any trailing
      # input. This will ensure that we can still highlight the input correctly, even when the
      # input contains some additional characters at the end that don't match the grammar.)
      self._re_prefix_with_trailing_input = [
          re.compile(
              r"(?:%s)(?P<%s>.*?)$"
              % (t.rstrip("$"), _INVALID_TRAILING_INPUT),
              flags,
          )
          for t in self._re_prefix_patterns
      ]
  
imports: from __future__ import unicode_literals
  import re
  from six.moves import range
  from .regex_parser import Any, Sequence, Regex, Variable, Repeat, Lookahead
  from .regex_parser import parse_regex, tokenize_regex
label_desc: Use image node_id 1 to create a new _CompiledGrammar object from inherited base classes: object with example: obj = _CompiledGrammar(root_node, escape_funcs, unescape_funcs)