let parse_gen f str = try Some (f (Lexing.from_string str)) with | _ -> None