Definition
Compilation happens in six logical phases, front-end (language-dependent) followed by back-end (machine-dependent), with the symbol table and error handler interacting across all phases.
Key Points (in order)
Example
For x = a + b * 2:
id(x) = id(a) + id(b) * num(2)a, b, x are declared & type-compatiblet1 = b*2; t2 = a+t1; x = t2📌 CSS Frequency: High — diagram/labeling question almost every attempt; sometimes asked to trace one phase with an example expression.
Model Answer (short)
"A compiler works in six phases: lexical analysis (tokenization), syntax analysis (parsing), semantic analysis (type/scope checking), intermediate code generation, code optimization, and code generation. The symbol table and error handler support every phase. The first three phases form the analysis (front-end); the last three form the synthesis (back-end), which allows retargeting to different machines by only rewriting the back-end."