These days there are more cross programming language compilers (specially from some ‘X’ language to JavaScript). I wonder how these are developed? What are the general steps to be taken care to write algorithms if I were to develop one?
Do I need to be completely thorough in Lexical Analysis?
As far as my knowledge is concerned they should follow the same steps of translating some ‘X’ language to Assembly language (basic compilation). Is that how they actually been developed? OR there is some different way?
Thanks
3
You’re essentially right. A “standard” compiler can be thought of as a cross-language compiler that translates [input language] into machine code. Once you understand that, the rest becomes clear.
The front-end (lexical, syntactical and semantic analysis) is all the same. You read the input language and develop an abstract syntax tree from it. What’s different is the backend. Once you’ve got your AST, the code generator outputs code that expresses the same concepts in a different human-readable programming language, instead of machine code.
1
All compilers compile from a source language to a target language, the only difference with these translators is the target language is much higher level than with a traditional compiler. Consequently you should look for general compiler resources.
Lexical analysis is not strictly speaking necessary (at least not as a separate step) however it is often used to speed up the parsing phase