let rec packages_parser ?(request=false) archs (req,acc) p =
  let filter par = 
    let match_field f p =
      try 
        begin match Packages.assoc f p with
        |(_,("Yes"|"yes"|"True" |"true")) -> true
        |(_,("No" |"no" |"False"|"false")) -> false
        |-> false
        end
      with Not_found -> false
    in
    let inst () = match_field "installed" par in 
    let candidate () = match_field "apt-candidate" par in
    ((inst ()) || (candidate ()))
  in
  match Format822_parser.stanza_822 Format822_lexer.token_822 p.Format822.lexbuf with
  |None -> (req,acc) (* end of file *)
  |Some stanza when request = true -> 
      let req = parse_request_stanza stanza in
      packages_parser archs (req,acc) p
  |Some stanza when req.strict_pin = true -> begin
    match (Packages.parse_package_stanza (Some(filter)) archs extras stanza) with
    |None -> packages_parser archs (req,acc) p
    |Some st -> packages_parser archs (req,st::acc) p
  end
  |Some stanza when req.strict_pin = false -> begin
    match (Packages.parse_package_stanza None archs extras stanza) with
    |None -> assert false (* this is not possible in this branch *)
    |Some st -> packages_parser archs (req,st::acc) p
  end
  |-> assert false