docs: def mark_quoted_strings(sql):
      """Mark all quoted strings in the SOQL by '@' and get them as params,
      with respect to all escaped backslashes and quotes.
      """
      # pattern of a string parameter (pm), a char escaped by backslash (bs)
      # out_pattern: characters valid in SOQL
      pm_pattern = re.compile(r"'[^\\']*(?:\\[\\'][^\\']*)*'")
      bs_pattern = re.compile(r"\\([\\'])")
      out_pattern = re.compile(r"^(?:[-!()*+,.:<=>\w\s|%s])*$")
      missing_apostrophe = "invalid character in SOQL or a missing apostrophe"
      start = 0
      out = []
      params = []
      for match in pm_pattern.finditer(sql):
          out.append(sql[start:match.start()])
          assert out_pattern.match(sql[start:match.start()]), missing_apostrophe
          params.append(bs_pattern.sub('\\1', sql[match.start() + 1:match.end() - 1]))
          start = match.end()
      out.append(sql[start:])
      assert out_pattern.match(sql[start:]), missing_apostrophe
      return '@'.join(out), params