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.
Asked
Active
Viewed 90 times
2
-
You mean like automatic translation? – greatwolf Aug 12 '13 at 07:39
-
2Yes, 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
-
1There 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
-
2Well 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