Phases of Compiler
- Finite Automata basics
- Programming syntax structures
Introduction
Compiler ek language translator program hai jo high-level programming language code (like C++) ko compile karke low-level machine code target me convert karta hai. Yeh conversion 6 phases me pipeline structured format me complete hota hai.
Real-Life Analogy
💡 Translating & Proofreading an English Book to Hindi
Phased verification and translation
| Concept Term | Real-life Analogy Mapping |
|---|---|
| Lexical Analysis | Dividing long paragraphs into individual vocabulary words (checking spelling). |
| Syntax Analysis | Checking sentence grammar (Subject + Verb + Object structure mapping). |
| Semantic Analysis | Checking logical sense (e.g., 'The table is drinking water' is grammatically correct, but logically invalid). |
| Code Optimization | Removing duplicate sentences and paragraphs to make the book shorter and cheaper. |
Detailed Concept Explanation
Compiler phases pipeline: 1. **Lexical Analyzer (Scanner)**: Input stream ko tokens (identifiers, keywords) me break karta hai. 2. **Syntax Analyzer (Parser)**: Tokens collection se Syntax Parse Tree check karta hai check syntax grammar rules. 3. **Semantic Analyzer**: Checks type checking and logical consistency. 4. **Intermediate Code Generator (ICG)**: Machine-independent code representation build karta hai. 5. **Code Optimizer**: Reduces execution clock cycles. 6. **Code Generator**: Converts intermediate code to target Assembly/Machine code.
Visual Diagram
- Symbol Table manager and Error Handler connect to all 6 phases.
- Lexical analyzer uses Regular Expressions; Syntax analyzer uses Context-Free Grammar.
L-S-S-I-C-C (Little Students Study In Class Chambers)
Lexical, Syntax, Semantic, Intermediate code, Code optimization, Code generation
Practice Mini Quiz
Revision Summary (One-Page Notes)
- •Compiler transforms high-level source to machine code.
- •Operates in six sequential phases connected to the Symbol Table.