0% found this document useful (0 votes)
14 views11 pages

Compiler Design

Uploaded by

praveenbarath29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views11 pages

Compiler Design

Uploaded by

praveenbarath29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

SIMATS ENGINEERIN

Saveetha Institute of Medical and Technical Sciences


Chennai-602105.

Error Detection and Recovery in a Simple


Compiler

Presentation By:
HariPriya S S(192371004)
Praveenkumar G (192424032)
VamsiKrishna L(192425054)
Abstract
Lexical Errors – Invalid tokens, illegal characters

Syntax Errors – Missing brackets, incorrect structure

Semantic Errors – Type mismatches, undeclared variables

Error Detection – During lexical, syntax, and semantic analysis


Introduction
 A compiler translates source code into machine-readable instructions

 Errors can occur during lexical, syntax, or semantic analysis

 Detecting errors early improves code reliability and debugging

 Recovery techniques help the compiler continue after encountering errors

 Essential for building robust and user-friendly programming tools


Objectives
To identify and categorize common compiler errors

To implement error detection during lexical, syntax, and semantic analysis

To explore error recovery techniques for uninterrupted compilation

To enhance compiler reliability and user feedback

To support efficient debugging and improve code qualit


Module 1:Types of Errors in Compilation

Lexical Errors – Invalid tokens, illegal characters, unmatched strings

Syntax Errors – Missing operators, unbalanced parentheses, incorrect grammar

Semantic Errors – Type mismatches, undeclared variables, incompatible assignments

Logical Errors – Unreachable code, infinite loops (optional in advanced compilers)

Importance – Early error identification improves code reliability and debugging


Algorithm
 Scan source code and perform lexical analysis to identify invalid tokens

 Parse tokens using grammar rules to detect syntax errors

 Analyze semantics to check for type mismatches and undeclared identifiers

 Log errors with relevant details and apply recovery strategies

 Continue compilation if possible, or halt with a summary of detected errors


Module 2: Error Detection Techniques

Lexical Analysis – Scans source code for invalid tokens and characters

Syntax Analysis – Builds parse trees to detect structural issues

Semantic Analysis – Uses symbol tables and type checking for logical consistency

Error Reporting – Generates meaningful messages to guide the programmer

Integration – Detection embedded in each compilation phase for efficiency


Module 3: Error Recovery
Strategies

Panic Mode Recovery – Skips input until a synchronizing token is found

Phrase-Level Recovery – Makes local corrections to continue parsing

Error Productions – Uses augmented grammar to handle common mistakes

Global Correction – Attempts minimal changes for closest valid code (rarely used)

Objective – Prevent abrupt termination and support smooth compilation flow


Work flow
Start / Login
Semantic Analysis

Code Generation
Lexical Analysis Error Detection

Syntax Analysis Error Recovery


Conclusion
 Error handling is a vital component of compiler design

 Early detection improves code reliability and user productivity

 Recovery techniques allow continued compilation despite faults

 Lexical, syntax, and semantic checks ensure thorough validation

 A robust compiler enhances debugging and supports better programming practices


Thank You

You might also like