From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr 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 162B27FD92 for ; Mon, 20 Jun 2016 16:15:19 +0200 (CEST) IronPort-PHdr: 9a23:c2uujRJkD6DS6ZaVFdmcpTZWNBhigK39O0sv0rFitYgUIvTxwZ3uMQTl6Ol3ixeRBMOAu6MC2red7f+ocFdDyKjCmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBybrysXNWC3oLmiqvspNX6WEZhunmUWftKNhK4rAHc5IE9oLBJDeIP8CbPuWZCYO9MxGlldhq5lhf44dqsrtY4q3wD89pozcNLUL37cqIkVvQYSW1+ayFmrPHs4CnKUwqC/DMiW2NenhcAPA/I9w3rWJq55jvzqOtwwgGWMNfwTL0uUi6jqaZsHkzGkiACYhc/7GbRwuZ5h6Japlr1rhpj2YnSaoieNPt4VqzYdNIeA2FGW5ACBGR6HoqgYt5XXKI6NuFCoty4/gNWoA== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=antronbachin@gmail.com; spf=Pass smtp.mailfrom=antronbachin@gmail.com; spf=None smtp.helo=postmaster@mail-io0-f180.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of antronbachin@gmail.com) identity=pra; client-ip=209.85.223.180; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="antronbachin@gmail.com"; x-sender="antronbachin@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of antronbachin@gmail.com designates 209.85.223.180 as permitted sender) identity=mailfrom; client-ip=209.85.223.180; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="antronbachin@gmail.com"; x-sender="antronbachin@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-io0-f180.google.com) identity=helo; client-ip=209.85.223.180; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="antronbachin@gmail.com"; x-sender="postmaster@mail-io0-f180.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AYAQCM+WdXf7TfVdFdgnqBGn2pdIVLhiaFAYF6JoU3OgKBMTgUAQEBAQEBAQERAQEJCwsJHzGCMYIaAQEBAwESEQoTARsdAQMBCwYFCw0qAgIjEQEFARwGEyKHcwEDDwgOojuBMT4xizuBaoJZBYchChknDVKDDAEBAQEBAQEBAQEBAQEBAQEBAQEBARQCBhCBBIcKglaCYIINglQTGIIvBY11dIoNhgaIJII3hwAOhV2OODCBDx6CMYFFTlAFikMBAQE X-IPAS-Result: A0AYAQCM+WdXf7TfVdFdgnqBGn2pdIVLhiaFAYF6JoU3OgKBMTgUAQEBAQEBAQERAQEJCwsJHzGCMYIaAQEBAwESEQoTARsdAQMBCwYFCw0qAgIjEQEFARwGEyKHcwEDDwgOojuBMT4xizuBaoJZBYchChknDVKDDAEBAQEBAQEBAQEBAQEBAQEBAQEBARQCBhCBBIcKglaCYIINglQTGIIvBY11dIoNhgaIJII3hwAOhV2OODCBDx6CMYFFTlAFikMBAQE X-IronPort-AV: E=Sophos;i="5.26,498,1459807200"; d="scan'208,217";a="223142678" Received: from mail-io0-f180.google.com ([209.85.223.180]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 20 Jun 2016 16:15:18 +0200 Received: by mail-io0-f180.google.com with SMTP id 5so131371518ioy.1 for ; Mon, 20 Jun 2016 07:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:subject:from:in-reply-to:date:cc:message-id:references :to; bh=cV7CXRNnWMnJojn1wtGfPyvw/bYiHaPdtjGjdzW8Hs4=; b=0RWUskRWsdvsfSjAPndshpqvD2V/HcnUd3WvDWdbJyuL0m0P5+t+0SwGEPB1SyEal1 OVY/dgyAL3n88/dJq2V/bg4hD0ej+19nBvPKw7GrIZp1/j7HXrLh2GKz6KmMpLCwtR1g 1vVHGFN05ileQy0j1mps37p69UhFyHB55Cbn/nD+URQkWLcCV0GwNHGXYM2ijJnED41P /CaA85SEPlYSBQALiz9fBTay4Jz4QWZOdXnM53gmQP/Mct/RCxvK6ZWWC/k3khiTt1XJ xKsK/TL3dq+PZaFWUE32ts3UUXuigq9DS5cb9raFTwAvVGdLL0XVvK4ePLcLKadDYnib Pk9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=cV7CXRNnWMnJojn1wtGfPyvw/bYiHaPdtjGjdzW8Hs4=; b=fzjDrSSXKP0/1TlpgPaIQN/CGgoGXHtUq4ZYXGDYRsLQhTcRPn6S6Vp+pkhbvhJBKu tdXgPoovD0JMWh5s/Tb/l9w0hbPh7g4rNRjSENTkAb2aHok7zLSPIDT2Ol0idbnvrGSn /eT95/LfYDG8P1WzrUpU9iQ5U+MskyRFgt/Jes5VyQK7eUuc12qUh452bqaqL1J3yzEl FEecELBO8tGXpJCMPm/cLFf+pqW1otx6O7A45RLYywq90C4Uds/MOy8HA8MvBRgJtQH1 FnE9gtVIrIJ93Ftc++vn2IOzuSSeF0ADG4M50KOOnFvvK0EvJGi03crODC5eNCPUHE9y hC7A== X-Gm-Message-State: ALyK8tJCvJ+TggczzvqM3a6xAk1YcYCVH1HWjnvtLm31pZSFMHfqX2ME/jDYW9Wy0/BJDQ== X-Received: by 10.107.14.71 with SMTP id 68mr24242973ioo.47.1466432116799; Mon, 20 Jun 2016 07:15:16 -0700 (PDT) Received: from [192.168.0.69] (c-73-9-77-177.hsd1.il.comcast.net. [73.9.77.177]) by smtp.gmail.com with ESMTPSA id 76sm29687804ioh.26.2016.06.20.07.15.16 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Jun 2016 07:15:16 -0700 (PDT) Content-Type: multipart/alternative; boundary="Apple-Mail=_E5524DAC-6376-4BD7-94D6-13078785AC6F" Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) From: Anton Bachin In-Reply-To: <5svasb3if71ppb0qpbzii4kmx-2147483647@mailer.nylas.com> Date: Mon, 20 Jun 2016 09:15:17 -0500 Cc: caml-list X-Mao-Original-Outgoing-Id: 488124916.978736-e53766200f353a7a569617ee66c0b1e7 Message-Id: References: <5svasb3if71ppb0qpbzii4kmx-2147483647@mailer.nylas.com> To: Xavier Van de Woestyne X-Mailer: Apple Mail (2.2070.6) Subject: Re: [Caml-list] Information for writting a ppx --Apple-Mail=_E5524DAC-6376-4BD7-94D6-13078785AC6F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi Xavier, Bisect_ppx does this by looking at the location of each module it sees in = =E2=80=9Cstructure". The file names are stored in a set. If a file name is = not yet in the set, Bisect_ppx assumes that the module is the top-level mod= ule of a file. We haven=E2=80=99t had any problems with it. You can see it here: https://github.com/aantron/bisect_ppx/blob/afa95d9f02a= b4c95df3af283641c73ec1dc8cfb1/src/syntax/instrumentPpx.ml#L480 The code is a bit old, but there it is. Best, Anton > On Jun 17, 2016, at 12:10, Xavier Van de Woestyne = wrote: >=20 > Hello,=20 > I have writted some ppx extension but I have a question,=20 > Is there a proper way to add a start "file" structure. > I have try using the "structure" member of the mapper :=20 >=20 > ` > let new_mapper =3D > Ast_mapper.{ > default_mapper with > structure =3D general_structure > }` >=20 > Where general_structure is just a > `my_begining_structure :: List.map (...)` but my begining=20 > structure is repeated into each module. It is logic but I need=20 > to add my own structure only at the begining of my file. In an=20 > other project, I use a mandatory attribute ([@@@active_this_ppx]=20 > for example), but imho, it is not a good approach.=20 >=20 > Thanks a lot for your feedback and advices !=20 >=20 > Xavier Van de Woestyne > D=C3=A9veloppeur =C3=A0 Derniercri.io > http://derniercri.io >=20 --Apple-Mail=_E5524DAC-6376-4BD7-94D6-13078785AC6F Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Hi= Xavier,

Bisect_p= px does this by looking at the location of each module it sees in =E2=80=9C= structure". The file names are stored in a set. If a file name is not yet i= n the set, Bisect_ppx assumes that the module is the top-level module of a = file. We haven=E2=80=99t had any problems with it.

The code is a bit old, but there it is.

Best,
Anton

On Jun 17,= 2016, at 12:10, Xavier Van de Woestyne <xavier@derniercri.io> wrote:

Hello, 
I have writted some ppx extension= but I have a question, 
Is there a proper way to= add a start "file" structure.
I have t= ry using the "structure" member of the mapper : 

`
let new_mapper =3D
 Ast_mapper.{
   default_mapper with
   struct= ure =3D general_structure
 }`

Where general_structu= re is just a
`my_begining_structure :: List.map (= ...)` but my begining 
structure is repeated into= each module. It is logic but I need 
to add my o= wn structure only at the begining of my file. In an 
other project, I use a mandatory attribute ([@@@active_this_ppx] = ;
for example), but imho, it is not a good approach.&n= bsp;

Thanks a lot= for your feedback and advices ! 

=
Xavier Van de Woestyne
D=C3=A9veloppeur =C3=A0 Derniercri.io

= --Apple-Mail=_E5524DAC-6376-4BD7-94D6-13078785AC6F--