Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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

share|improve this question

closed as not a real question by Glenn Nelson, MichaelT, Kilian Foth, Yusubov, Rein Henrichs May 2 '13 at 1:40

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

3  
According to the FAQ's don't ask section, questions that would require a whole book (or in this case, many books) is off topic. Can you edit the question to narrow the scope? –  Dan Pichelman May 1 '13 at 15:21
1  
Disagree that this requires a whole book to answer, do agree that some tweaks to the question would be good (suggest you remove the resource request as this is likely to get the q closed as off topic) –  jk. May 1 '13 at 15:40
    
@jk - thanks for your suggestion –  poddroid May 1 '13 at 15:43
    
Things may get interesting if your goal is to produce a readable and idiomatic output. In such case, translation techniques may be different from a traditional compilation. A good example is P#: citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.105.495 –  SK-logic May 1 '13 at 16:23
add comment

2 Answers

up vote 4 down vote accepted

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.

share|improve this answer
    
Thank you. So I should start on reading the compiler design. Well I will search for the books on it. –  poddroid May 1 '13 at 15:45
add comment

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

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.