My understanding is that a self-hosting compiler will take as input the language it is written in and a cross-compiler will output a language which runs on a platform which is different to what it runs on.
Can we combine these two compiler types into one?
Asked By : Haych
Answered By : jmite
This is certainly possible, and there are two possibilities:
There are two compilers for a language. For example, Haskell has GHC, and GHCJS, which is a JavaScript cross-compiler. GHC is written in Haskell, and GHCJS is written in Haskell (and normally compiled with GHC), so GHCJS is a self-hosted cross-compiler.
You run your self-hosted cross-compiler in a target language. So, if you had a Foo to Python cross-compiler, and it's the only compiler for Foo, and it's written in Foo, it can be self hosting, but you would have to cross-compile it, then run the result in a Python interpreter.
Basically, be careful that you don't confuse a language with a compiler. A language can have many compilers.
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/56531
0 comments:
Post a Comment
Let us know your responses and feedback