Hi Xavier, Bisect_ppx does this by looking at the location of each module it sees in “structure". 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 module of a file. We haven’t had any problems with it. You can see it here: https://github.com/aantron/bisect_ppx/blob/afa95d9f02ab4c95df3af283641c73ec1dc8cfb1/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: > > 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 try using the "structure" member of the mapper : > > ` > let new_mapper = > Ast_mapper.{ > default_mapper with > structure = general_structure > }` > > Where general_structure 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 own 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. > > Thanks a lot for your feedback and advices ! > > Xavier Van de Woestyne > Développeur à Derniercri.io > http://derniercri.io >