开发者

Tool for automated porting and language that can compile into others

I'm just asking this out of curiosity :

  • Is there any tool that can automatically convert a 开发者_运维知识库source code of reasonable complexity from one language to another ?
  • Is there any "meta-language" that can compile into several other languages ? For example CoffeeScript compiles into Javascript.

If you know any open-source example, it'd be great !

Thank you for your time.

PS: No idea how to tag this. Feel free to edit.


GCC converts complex C++ code into machine code and thus technically is an answer to your question. In fact, there are lots of compiler like this, but I don't think these are what you intended to ask.

There are tools that are hardwired to translate just one language to another as source code (another poster suggested "f2C", which is a perfect example). These are just like compilers... but rarer.

There are virtually no tools that will map from one language to many others, out of the box. The problem is that languages have different execution models, data types, and execution schemes, which such a translator has to simulate properly in the target language. The are "code generators" that claim to do this, but they are largely IMHO specifications of rather simple functions that translate trivially to simple code in the target langauge.

If you want to translate one language to another in a sort of general way, you need a program transformation system, e.g., a system that can parse arbitrary langauges, and for which you can provide translation rules that map to other languages in a sort of straightforward way.

Our DMS Software Reengineering Toolkit is one of these. This SO What kinds of patterns could I enforce on the code to make it easier to translate to another programming language? discusses the issues in more detail.


You can convert Fortran code to C using the f2c tool.

For python, you can convert a subset of the language to C++ using shedskin.

The vala language is converted to C before the real compilation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜