From: Dmitry Bely <dmitry.bely@gmail.com>
To: Caml List <caml-list@inria.fr>
Subject: [Caml-list] ppx_metaquot location passing
Date: Wed, 2 Sep 2015 11:23:06 +0300 [thread overview]
Message-ID: <CAMT7qiROs6YEWrRLVPhSeW71W8SzSeeiftKfK-=xFck3ZkMMFQ@mail.gmail.com> (raw)
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
next reply other threads:[~2015-09-02 8:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-02 8:23 Dmitry Bely [this message]
2015-09-02 9:09 ` Alain Frisch
2015-09-02 9:47 ` Dmitry Bely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMT7qiROs6YEWrRLVPhSeW71W8SzSeeiftKfK-=xFck3ZkMMFQ@mail.gmail.com' \
--to=dmitry.bely@gmail.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox