Skip to content

Instantly share code, notes, and snippets.

@xvw
Created March 5, 2016 15:14
Show Gist options
  • Save xvw/7a2397cde4c73bccc65c to your computer and use it in GitHub Desktop.
Save xvw/7a2397cde4c73bccc65c to your computer and use it in GitHub Desktop.
open Printf
open Parsetree
open Asttypes
open Ast_helper
let create_loc ?(loc = !default_loc) value = {
txt = value
; loc = loc
}
let structure_item mapper item =
match item.pstr_desc with
| Pstr_type declarations ->
printf "found type\n";
Str.attribute (create_loc "test", PStr [])
| _ -> Ast_mapper.(default_mapper.structure_item mapper item)
let structure mapper strct =
List.map (fun x -> x) strct
let item_mapper =
Ast_mapper.{
default_mapper with
structure_item = structure_item;
structure = structure
}
let () =
Ast_mapper.run_main (fun argv -> item_mapper)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment