code: def split_trailing_comment(line: str) -> str:
      
  
      if line.find("!") == -1:
          return (line, None)
  
      i = 0
      while i < len(line):
          if line[i] == "'":
              j = line.find("'", i + 1)
              if j == -1:
                  sys.stderr.write("WEIRD: unbalanced quote ': line = " + line)
                  return line
              else:
                  i = j + 1
          elif line[i] == '"':
              j = line.find('"', i + 1)
              if j == -1:
                  sys.stderr.write('WEIRD: unbalanced quote ": line = ' + line)
                  return line
              else:
                  i = j + 1
          elif line[i] == "!":  # partial-line comment
              comment_part = line[i:]
              code_part = line[:i].rstrip() + "\n"
              return (code_part, comment_part)
          else:
              i += 1
  
      return (line, None)
docs: Takes a line and splits it into two parts (code_part, comment_part)
      where code_part is the line up to but not including any trailing
      comment (the '!' comment character and subsequent characters
      to the end of the line), while comment_part is the trailing comment.
  
      Args:
          line: A line of Fortran source code.
  
      Returns:
          A pair (code_part, comment_part) where comment_part is the trailing
          comment.  If the line does not contain any trailing comment, then
          comment_part is None.