parameters: (header_file)
return_statement: return extensions
docstring: Parse a C extension header file and return a map from extension names to
    a list of functions.
  
    Args:
      header_file: Line-iterable C header file.
    Returns:
      Map of extension name => functions.
docstring_summary: Parse a C extension header file and return a map from extension names to
    a list of functions.
docstring_tokens: Parse a C extension header file and return a map from extension names to a list of functions .
function: def ParseExtensionFunctionsFromHeader(header_file):
    """Parse a C extension header file and return a map from extension names to
    a list of functions.
  
    Args:
      header_file: Line-iterable C header file.
    Returns:
      Map of extension name => functions.
    """
    extension_start = re.compile(r'#define ([A-Z]+_[A-Z]+_[a-zA-Z]\w+) 1')
    extension_function = re.compile(r'.+\s+([a-z]+\w+)\s*\(.+\);')
    typedef = re.compile(r'typedef .*')
    macro_start = re.compile(r'^#(if|ifdef|ifndef).*')
    macro_end = re.compile(r'^#endif.*')
    macro_depth = 0
    current_extension = None
    current_extension_depth = 0
    extensions = collections.defaultdict(lambda: [])
    for line in header_file:
      if macro_start.match(line):
        macro_depth += 1
      elif macro_end.match(line):
        macro_depth -= 1
        if macro_depth < current_extension_depth:
          current_extension = None
      match = extension_start.match(line)
      if match:
        current_extension = match.group(1)
        current_extension_depth = macro_depth
        assert current_extension not in extensions, \
            "Duplicate extension: " + current_extension
      match = extension_function.match(line)
      if match and current_extension and not typedef.match(line):
        extensions[current_extension].append(match.group(1))
    return extensions
function_tokens: def ParseExtensionFunctionsFromHeader ( header_file ) : extension_start = re . compile ( r'#define ([A-Z]+_[A-Z]+_[a-zA-Z]\w+) 1' ) extension_function = re . compile ( r'.+\s+([a-z]+\w+)\s*\(.+\);' ) typedef = re . compile ( r'typedef .*' ) macro_start = re . compile ( r'^#(if|ifdef|ifndef).*' ) macro_end = re . compile ( r'^#endif.*' ) macro_depth = 0 current_extension = None current_extension_depth = 0 extensions = collections . defaultdict ( lambda : [ ] ) for line in header_file : if macro_start . match ( line ) : macro_depth += 1 elif macro_end . match ( line ) : macro_depth -= 1 if macro_depth < current_extension_depth : current_extension = None match = extension_start . match ( line ) if match : current_extension = match . group ( 1 ) current_extension_depth = macro_depth assert current_extension not in extensions , "Duplicate extension: " + current_extension match = extension_function . match ( line ) if match and current_extension and not typedef . match ( line ) : extensions [ current_extension ] . append ( match . group ( 1 ) ) return extensions