0% found this document useful (0 votes)
1 views

Compiler Design CAT Answers

The document outlines the key components and phases of compiler design, including lexical analysis, syntax analysis, and semantic analysis. It discusses the importance of tokens, the role of the symbol table, error recovery strategies, and various classifications of compilers. Additionally, it covers optimization techniques and the significance of intermediate code in enhancing portability and performance.

Uploaded by

Collins Bett
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Compiler Design CAT Answers

The document outlines the key components and phases of compiler design, including lexical analysis, syntax analysis, and semantic analysis. It discusses the importance of tokens, the role of the symbol table, error recovery strategies, and various classifications of compilers. Additionally, it covers optimization techniques and the significance of intermediate code in enhancing portability and performance.

Uploaded by

Collins Bett
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

INTRODUCTION TO COMPILER DESIGN CAT ANSWERS

1. Phases of the Front End of a Compiler:


- Lexical Analysis: Tokenizes the source code.
- Syntax Analysis: Constructs parse trees.
- Semantic Analysis: Ensures logical correctness.

2. Lexemes to Tokens & Importance of Tokens:


- Lexical analyzer groups characters into lexemes.
- Converts lexemes into tokens.
- Tokens simplify syntax analysis.

3. Role of Symbol Table:


- Stores variable names, types, and scopes.
- Facilitates type checking and optimization.

4. Error Recovery Strategies:


- Panic Mode: Skips erroneous statements.
- Phrase-Level: Attempts local corrections.
- Error Productions: Anticipates likely errors.
- Global Correction: Modifies code for correctness.

5. Classifications of a Compiler:
- Single-Pass vs Multi-Pass.
- Just-In-Time (JIT) Compilation.
- Cross Compiler.
- Incremental Compiler.

6. Passes in Compiler Design:


- Single-Pass Compiler: Reads code once.
- Multi-Pass Compiler: Processes code multiple times for optimization.
7. Types of Parsing:
- Top-Down Parsing (LL Parsing).
- Bottom-Up Parsing (LR Parsing).

8. Architecture of a Compiler:
- Consists of lexical, syntax, semantic analysis, intermediate code generation, optimization, and
code generation.

9. Peephole Optimization:
- A small code segment optimization technique.
- Eliminates redundant instructions.

10. Code Optimization:


- Enhances execution efficiency and performance.

11. Code Optimization Techniques:


- Constant Folding.
- Dead Code Elimination.
- Loop Unrolling.
- Strength Reduction.

12. Lexical Analysis Phase:


- Converts source code to tokens.
- Identifies keywords, identifiers, and symbols.

13. Outputs of Preprocessor Phase:


- Expanded macros.
- File inclusions.
- Conditional compilation results.
- Comment removal.

14. Reasons for Intermediate Code:


- Enhances portability.
- Simplifies optimization.
- Bridges high-level and machine code.
- Enables retargeting for different architectures.

You might also like