From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id E640A7F0A3 for ; Wed, 2 Sep 2015 11:09:34 +0200 (CEST) IronPort-PHdr: 9a23:bpSPJRA57SP4oISpLy7LUyQJP3N1i/DPJgcQr6AfoPdwSP/7osbcNUDSrc9gkEXOFd2CrakU16yO6+jJYi8p39WoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6kO74TNaIBjjLw09fr2zQd6OyZzvn8mJuLTtICxwzAKnZr1zKBjk5S7wjeIxxbVYF6Aq1xHSqWFJcekFjUlhJFaUggqurpzopM0r221qtvkg789NV7nhN+R9FOQATWduD2dgyMjqqQPSBSGC4mpUBmkTkwZSEk7P4RXrdpj0uyr+8OF63X/edeb/SLR8fTW58+8/QxbtjGIDNiUl2GDRkM15yqxB9kGPvRt6lqfQaYCTfNRkf7jWfZtOTG5IX8AXWTZAGYi8R48CH+sPPKBTqIyr9AhGlge3GQT5XLCn8TRPnHKjmPRii+k= Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=alain.frisch@lexifi.com; spf=None smtp.mailfrom=alain.frisch@lexifi.com; spf=None smtp.helo=postmaster@mx20.yaziba.net Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain.frisch@lexifi.com) identity=pra; client-ip=85.233.204.164; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="alain.frisch@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain.frisch@lexifi.com) identity=mailfrom; client-ip=85.233.204.164; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="alain.frisch@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mx20.yaziba.net) identity=helo; client-ip=85.233.204.164; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="postmaster@mx20.yaziba.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0ABAgCbu+ZVnKTM6VVdh3vAEoJYAoFFPBABAQEBAQEBARABAQEBAQgLCQkhLoIdggcBAQQjBBFAEQsYAgIFFgsCAgkDAgECAUUGAQwIAQGILrRVlRABAQgBAQEBHoEihVGEe4RYOoJpgUMBBJVJjHaIeIV5i3wChCeDPAEBAQ X-IPAS-Result: A0ABAgCbu+ZVnKTM6VVdh3vAEoJYAoFFPBABAQEBAQEBARABAQEBAQgLCQkhLoIdggcBAQQjBBFAEQsYAgIFFgsCAgkDAgECAUUGAQwIAQGILrRVlRABAQgBAQEBHoEihVGEe4RYOoJpgUMBBJVJjHaIeIV5i3wChCeDPAEBAQ X-IronPort-AV: E=Sophos;i="5.17,452,1437429600"; d="scan'208";a="175715384" Received: from mx20.yaziba.net ([85.233.204.164]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 02 Sep 2015 11:09:34 +0200 Received: from mta10.int.yaziba.net (unknown [10.4.20.30]) by mx20.yaziba.net (mx10.yaziba.net) with ESMTP id 07B7A1A7499; Wed, 2 Sep 2015 11:09:34 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mta10.int.yaziba.net (Postfix) with ESMTP id 33613CA732; Wed, 2 Sep 2015 11:09:34 +0200 (CEST) X-Virus-Scanned: amavisd-new at mta10.int.yaziba.net Received: from mta10.int.yaziba.net ([127.0.0.1]) by localhost (mta10.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JnfVk4cdNWVy; Wed, 2 Sep 2015 11:09:34 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mta10.int.yaziba.net (Postfix) with ESMTP id 0C80DCA72A; Wed, 2 Sep 2015 11:09:34 +0200 (CEST) X-Virus-Scanned: amavisd-new at mta10.int.yaziba.net Received: from mta10.int.yaziba.net ([127.0.0.1]) by localhost (mta10.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 1B0nj-N2wZ99; Wed, 2 Sep 2015 11:09:33 +0200 (CEST) Received: from [10.0.210.18] (unknown [185.23.92.144]) by mta10.int.yaziba.net (Postfix) with ESMTPSA id E5218CA732; Wed, 2 Sep 2015 11:09:33 +0200 (CEST) To: Dmitry Bely , Caml List References: From: Alain Frisch Message-ID: <55E6BCCB.1040602@lexifi.com> Date: Wed, 2 Sep 2015 11:09:31 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-DRWEB-SCAN: ok X-VRSPAM-SCORE: -100 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrfeekgedrtddvgddufecutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpjgetkgfkueetnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefuvfhfhffkffgfgggjtgfgsehtjegrtddtfeejnecuhfhrohhmpeetlhgrihhnucfhrhhishgthhcuoegrlhgrihhnrdhfrhhishgthheslhgvgihifhhirdgtohhmqe X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht Subject: Re: [Caml-list] ppx_metaquot location passing Hi Dmitry, Looking at the comments in ppx_metaquot.ml, there are two ways to achieve that: - By default, the location of all created notes is set to the expression "!Ast_helper.default_loc". You can set this reference directly or with Ast_helper.with_default_loc. - You can change this expression with a @metaloc attribute (typically to specify a locally bound variable). Hope this helps, Alain On 02/09/2015 10:23, Dmitry Bely wrote: > 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 >