A program written in high level language produce output in low level language is called compiler.
A compiler that runs on one machine 'A' and produces a code for another machine 'B'.
Example: (a) Suppose Compiler runs on machine A, which takes language X as input and produces output in Y language.
(b) Suppose Compiler runs on machine A and produces code Y for another machine B.
There are two major parts of a compiler:
1. Analysis Phase: It breaks up the source program into constant piece and creates an intermediate representation of the source program.
(i) Lexical Analyzer
(ii) Syntax Analyzer
(iii) Semantic Analyzer
2. Synthesis Phase: It constructs the desired target program from the intermediate representation.
(i) Intermediate Code Generator
(ii) Code Generator
(iii) Code Optimizer
Lexical analyzer reads a source program character by character to produce tokens.