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.
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, create_group_func):
      """
      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):
          # Turn `Any` into an OR.
          if isinstance(node, Any):
              return "(?:%s)" % "|".join(
                  transform(c) for c in node.children
              )
  
          # Concatenate a `Sequence`
          elif isinstance(node, Sequence):
              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 "(?P<%s>%s)" % (
                  create_group_func(node),
                  transform(node.childnode),
              )
  
          # `Repeat`.
          elif isinstance(node, Repeat):
              return "(?:%s){%i,%s}%s" % (
                  transform(node.childnode),
                  node.min_repeat,
                  (
                      ""
                      if node.max_repeat is None
                      else str(node.max_repeat)
                  ),
                  ("" if node.greedy else "?"),
              )
          else:
              raise TypeError("Got %r" % (node,))
  
      return transform(root_node)
  
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 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, unknown, unknown