pyre-ast is an OCaml library that provides python AST representation in OCaml.
I had a need to do python source code transformations in OCaml. I made Opine to do transformations on the AST and convert it back to python. So, in OCaml, you can write python code now, if you ever need to.
P.S. It still doesn’t support the entire python syntax 100%. I haven’t added support for things like for-comprehension but it should be fairly easy to add it. I plan to add support for the missing ones as I need it for my projects.
Out of curiosity I looked at the code randomly and I see
It looks like you are building a large string by concatenating many small strings using the ( ^ ) operator, which has quadratic complexity. Unless I am missing something, this is wrong and you should be using buffers instead.