def parse_cpp_files(test_directory):
  """Parse cpp files looking for snippet marks.

  Args:
    test_directory: Directory to look for cpp files in.

  Returns:
    Tuple of file_list and snippet_list where file_list is a list of files that need to be
    updated with documentation and snippet_list is a dictionary of lists
    indexed by string tokens / identifiers.  The lists in the snippet_list dictionary
    contain lines of code snippets to be inserted at points identified by the
    token that indexes the set of lines.
  """
  file_list = []
  snippet_list = {}
  for path, dirs, files in os.walk(test_directory):
    for cpp_file in files:
      if not re.match(r'.*\.c(pp|c)$', cpp_file): continue
      parse_lines = False
      snippet_lines = []
      token = ''
      md_file = ''
      cpp_file_path = os.path.join(path, cpp_file)
      try:
        with open(cpp_file_path, 'r') as ccfile:
          for line in ccfile:
            match = CPPDOXYSNIPPETSTART_RE.match(line)
            if match:
              parse_lines = True
              group_dict = match.groupdict()
              md_file = group_dict['md_file']
              token = group_dict['token']
              if md_file not in file_list:
                file_list.append(md_file)
            elif DOXYSNIPPETEND_RE.match(line):
              parse_lines = False
              snippet_list[token] = snippet_lines
            elif parse_lines:
              snippet_lines.append(line)
      except __HOLE__ as e:
        print 'ERROR: Failed to open file %s: %s' % (cpp_file, e.strerror)
      if parse_lines is True:
        print 'WARNING: Count not find end of %s. Skipping.' % (token)
  return (file_list, snippet_list)
dataset/ETHPy150Open google/fplutil/docs/update_code_snippets.py/parse_cpp_files