2

I wanna convert an Ocaml file with extension .ml, .mll, .mly into .c/.cpp file. Is there any way in which it can be done.

djot
  • 2,952
  • 4
  • 19
  • 28
Arpit Sancheti
  • 248
  • 2
  • 12
  • You mean like automatic translation? – greatwolf Aug 12 '13 at 07:39
  • 2
    Yes, it can be done. Either learn the source and target languages, or hire somebody who already knows them. Rewrite as appropriate. I don't know of an automated tool that will translate Ocaml to maintainable C or C++ though. – Jerry Coffin Aug 12 '13 at 07:40
  • yes, I mean like automatic translation – Arpit Sancheti Aug 12 '13 at 07:43
  • 1
    There actually _might_ be a way using LLVM (but I haven't investigated): [LLVM can emit C files](http://fdiv.net/2012/11/16/llvm-generates-code-that-generates-code) as output. And there's a [LLVM OCaml frontend](https://github.com/bmeurer/ocaml). Good luck from here on ;-) – DarkDust Aug 12 '13 at 07:52
  • 2
    Well its not THAT crazy of a request... Haskell can be compiled to C code by ghc so it stands to reason that it is possible to exist for ocaml. But Google is a better place to find this out than SO. – scott_fakename Aug 12 '13 at 07:52
  • Possible duplicate: Is there any free OCaml to C translator? - http://stackoverflow.com/q/2638664/1243762 – Guy Coder Aug 12 '13 at 10:05
  • Just in case someone is curious: the LLVM OCaml frontend seems to be a long-dead project. – Næreen Feb 18 '21 at 23:29

0 Answers0