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: Turn a :class:`Node` object into a regular expression.
  
  :param root_node: The :class:`Node` instance for which we generate the grammar.
  :param create_group_func: A callable which takes a `Node` and returns the next
      free name for this node.
docstr_tok: ["Turn","a",":","class",":","`","Node","`","object","into","a","regular","expression",".",":","param","root_node",":","The",":","class",":","`","Node","`","instance","for","which","we","generate","the","grammar",".",":","param","create_group_func",":","A","callable","which","takes","a","`","Node","`","and","returns","the","next","free","name","for","this","node","."]
code: def _transform(
      cls, root_node: Node, create_group_func: Callable[[Variable], str]
  ) -> str:
      """
      Turn a :class:`Node` object into a regular expression.
  
      :param root_node: The :class:`Node` instance for which we generate the grammar.
      :param create_group_func: A callable which takes a `Node` and returns the next
          free name for this node.
      """
  
      def transform(node: Node) -> str:
          # Turn `AnyNode` into an OR.
          if isinstance(node, AnyNode):
              return "(?:%s)" % "|".join(
                  transform(c) for c in node.children
              )
  
          # Concatenate a `NodeSequence`
          elif isinstance(node, NodeSequence):
              return "".join(transform(c) for c in node.children)
  
          # For Regex and Lookahead nodes, just insert them literally.
          elif isinstance(node, Regex):
              return node.regex
  
          elif isinstance(node, Lookahead):
              before = "(?!" if node.negative else "(="
              return before + transform(node.childnode) + ")"
  
          # A `Variable` wraps the children into a named group.
          elif isinstance(node, Variable):
              return f"(?P<{create_group_func(node)}>{transform(node.childnode)})"
  
          # `Repeat`.
          elif isinstance(node, Repeat):
              if node.max_repeat is None:
                  if node.min_repeat == 0:
                      repeat_sign = "*"
                  elif node.min_repeat == 1:
                      repeat_sign = "+"
              else:
                  repeat_sign = "{%i,%s}" % (
                      node.min_repeat,
                      (
                          ""
                          if node.max_repeat is None
                          else str(node.max_repeat)
                      ),
                  )
  
              return "(?:{}){}{}".format(
                  transform(node.childnode),
                  repeat_sign,
                  ("" if node.greedy else "?"),
              )
          else:
              raise TypeError(f"Got {node!r}")
  
      return transform(root_node)
  
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 4 for calling the _CompiledGrammar obj's underlying member method code with example usage: obj._transform(cls, root_node, create_group_func) and returns: transform, unknown, str, node, unknown, str, create_group_func, str, transform, str, str