code: def _transform(cls, root_node, create_group_func):
          
          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)
docs: 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.