A compiler is a program that reads source language and translates it into another language. Typically, a compiler reads source code, translates it into machine language, and writes the machine language to binary (object) code that can be directly loaded and executed. Common compiled languages include C and C++.
An interpreter is similar in that it is a program that reads source code one statement at a time, translates that statement to machine language, executes the machine language statement, then continues with the next statement. Common interpreted languages include Java and PHP.
BASIC is sometimes interpreted and sometimes compiled. Although less convenient for programming, compilers are much faster than interpreters.
A compiler consists of many phases, each phase consisting of some of steps. Each phase take input from previous phase (except the first phase, which takes its input from the source code created by a programmer).
The input for this phase is a source code file, the output is set of tokens.
The input for this phase are set of tokens , the output is syntax tree.
The input for this phase is syntax tree , the output is annotated tree.
The input for this phase is annotated tree, the output is intermediate code.
The input for this phase is intermediate code, the output is target code.
The input for this phase is target code, the output is optimizing target code.