import re


def toExportName(name):
  """Convert name to .cpp -friendly name."""
  match = re.match(r'g_([^\.]+)(\.\d+)?', name)
  if not match:
    raise RuntimeError("name '%s' is not C++ -friendly" % (name))
  return match.groups(1)[0]