Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* [Caml-list] ppx_metaquot location passing
@ 2015-09-02  8:23 Dmitry Bely
  2015-09-02  9:09 ` Alain Frisch
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Bely @ 2015-09-02  8:23 UTC (permalink / raw)
  To: Caml List

I'm writing a ppx rewriter. It iterates over structure items and for
some of them generates the new ones. A simplified example:

let defs = ref []

let mapper argv =
  let expr mapper expr =
    ...
  let rec structure mapper li =
    let li =
      List.fold_left (fun acc ({pstr_loc = loc} as si) ->
        let si = default_mapper.structure_item mapper si in
        let sli =
          List.map
            (fun (n, v) ->
              [%stri let [%p pvar n] = [%e str v]])
            !defs in
        defs := [];
        (si::sli) @ acc) [] li in
    List.rev li
...

The question is how to pass the location information for [%stri]
generated code (loc in my example)? Of course I can write

{[%stri let [%p pvar n] = [%e str v]] with pstr_loc = loc}

but I would like the location of all nested expressions to be set to
loc as well.

- Dmitry Bely

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-02  9:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-02  8:23 [Caml-list] ppx_metaquot location passing Dmitry Bely
2015-09-02  9:09 ` Alain Frisch
2015-09-02  9:47   ` Dmitry Bely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox