let ident_tag ?(conv_lid = fun x -> x) i =
              let rec self i acc =
                match i with
                | Ast.IdAcc (_, i1, i2) -> self i2 (Some (self i1 acc))
                | Ast.IdApp (_, i1, i2) ->
                    let i' =
                      Lapply ((fst (self i1 None)), (fst (self i2 None))) in
                    let x =
                      (match acc with
                       | None -> i'
                       | _ ->
                           error (loc_of_ident i) "invalid long identifier")
                    in (x, `app)
                | Ast.IdUid (_, s) ->
                    let x =
                      (match acc with
                       | None -> lident s
                       | Some ((acc, (`uident | `app))) -> ldot acc s
                       | _ ->
                           error (loc_of_ident i) "invalid long identifier")
                    in (x, `uident)
                | Ast.IdLid (_, s) ->
                    let x =
                      (match acc with
                       | None -> lident (conv_lid s)
                       | Some ((acc, (`uident | `app))) ->
                           ldot acc (conv_lid s)
                       | _ ->
                           error (loc_of_ident i) "invalid long identifier")
                    in (x, `lident)
                | _ -> error (loc_of_ident i) "invalid long identifier"
              in self i None