PEC-DS501E
BY-Arka Dutta
November 5, 2025
0
,UNIT 1 — Introduction to Compiling:
Topic Importance
Compilers
Analysis of Source Program
Phases of Compiler (PYQ every year)
Cousins of Compiler
1. Compilers
PYQ Appearances:
• 2023 (3 marks)
• 2021 (3 marks)
• 2020 (5 marks)
A compiler is a software system that translates a program written in
a high-level programming language (HLL) into machine code that a
computer can execute.
Input to compiler → Source code (.c, .java etc.)
Output from compiler → Target Machine Code (Binary
executable).
Compilation happens before execution.
Errors are shown after full translation.
[“Compiler” = Translate before Run]
1
,2. Analysis of the Source Program
PYQ: 2022 (5 marks), 2020 (3 marks)
Two Main Parts in Compilation:
Parts Meaning Produces
Analysis Understands and checks Intermediate
(Front-End) source code Representation (IR)
Synthesis Converts IR to machine
Final Executable
(Back-End) code
Block Diagram (Exam Diagram)
Source Program
↓
[ Analysis]
(Lexical → Syntax → Semantic → IR)
↓
[ Synthesis]
(Code Optimization → Code Generation)
↓
Target Machine Code
2
, 3.Phases of Compiler (Most Important | Repeated every
year)
PYQ:
• 2023 Q7(a) — 5 marks
• 2022 Q13(b) — 5 marks
• 2021 Q4(b) — 5 marks
Phase Purpose Output
Converts characters →
Lexical Analysis Tokens
tokens
Checks grammar using
Syntax Analysis Parse Tree
parse tree
Checks meaning & type
Semantic Analysis Annotated Tree
compatibility
Intermediate Code Produces machine- IR (Three Address
Generation independent code Code)
Improves performance of
Code Optimization Optimized IR
IR
Converts optimized IR → Assembly /
Code Generation
machine code Machine Code
3