SlideShare a Scribd company logo
1 of 23
Md Mohib
Reg No- 20105124057
Branch- Computer Science &
Engineering
Semester- 6th
ERROR DETECTION &
RECOVERY
ERROR HANDLING
• It is an important feature of any compiler.
• A good compiler should be able to detect and
report errors.
• It should be able to modify input, when it finds
an error in lexical analysis phase.
• A more sophisticated compiler should be able
to correct the errors, by making guess of
user intentions.
ERROR HANDLING
• The most important feature of error handler is
correct and more centric error message.
• It should following properties:-
– Reporting errors in original source program,
rather than intermediate or final code.
– Error message shouldn’t be complicated.
– Error message shouldn’t be duplicated.
– Error message should localize the problem.
SOURCES OF ERROR
to meet the design may be
• Algorithmic Errors:-
– The algorithm used
inadequate or incorrect.
• Coding Errors:-
– The programmer may introduce syntax or logical errors
in implementing the algorithms.
SOURCES OF ERROR
• Lexical Phase:-
– wrongly formed identifiers (or tokens).
– Some character used which is undefined in PL.
– Addition of an extra character.
– Removal of a character that should be present.
– Replacement of a character with an incorrect characters.
– Transposition of 2 characters.
SOURCES OF ERROR
• Lexical Phase:-
– Best way to handle a lexical error is to find the closest
character sequence that does match a pattern (takes
long time & unpractical)
– Another way is to feed lexical analyzer – a list of
legitimate token available to the error recovery routines.
– Or generate an error.
SOURCES OF ERROR
• Syntactic:-
– Comma instead of a semi-colon.
– Misspelled keywords, operators.
– Two expressions not connected by operator.
– Null expression between parenthesis
– Unbalanced parenthesis
– Handle is absent
• Usually, panic mode or phrase-level recovery is
used.
SOURCES OF ERROR
• Semantic:
Declaration and scope errors like use of
undeclared or multi-declared identifiers, type
mismatch, etc.
In case of undeclared name, make an entry
in the Symbol table & its attributes.
Set a flag in ST that it was done due to an
error rather than declaration.
SOURCES OF ERROR
• Logical:
– Syntax is correct, but wrong logic applied to programmer.
– Most difficult to recover.
– Hard to detect by compiler.
GOALS OF ERROR HANDLER
meaningful
• Detect errors quickly and produce
diagnostic.
• Detect subsequent errors after an error correction.
• It shouldn’t slow down compilation.
GOALS OF ERROR HANDLER
Program submitted to a compiler often have errors of
various kinds:-
• So, good compiler should be able to detect as many errors
as possible in various ways.
• Even in the presence of errors, the compiler should
scan the program and try to compile all of it.(error
recovery).
GOALS OF ERROR HANDLER
• When the scanner or parser finds an error and
cannot proceed ?
• Then, the compiler must modify the input so that the
correct portions of the program can be pieced
together and successfully processed in the syntax
analysis phase.
CORRECTING COMPILER
• These compilers does the job of error recovery not only from the
compiler point of view but also from the programmers point of view.
• Ex:PL/C
• But, error recovery should not lead to misleading or spurious error
messages elsewhere (error propagation).
RUN-TIME ERRORS
• Indication of run time errors is another neglected
area in compiler design.
• Because, code generated to monitor these
violations increases the target program size, which
leads to slow execution.
• So these checks are included as “debugging
options”.
ERROR RECOVERY STRATEGIES
There are four common error-recovery strategies that
can be implemented in the parser to deal with errors
in the code:-
• Panic mode recovery
• Phrase-level recovery
• Error productions
• Global correction
ERROR RECOVERY STRATEGIES
Panic Mode Recovery:-
• Once an error is found, the parser intends to find
designated set of synchronizing tokens (delimiters,
semicolon or } ) by discarding input symbols one at
a time.
• When parser finds an error in the statement, it
ignores the rest of the statement by not processing
the input.
ERROR RECOVERY STRATEGIES
Panic Mode Recovery:-
• This is the easiest way of error-recovery.
• It prevents the parser from developing infinite loops.
• Ex: a=b + c // no semi-colon
• d=e + f ;
• The compiler will discard all subsequent tokens till a
semi-colon is encountered.
ERROR RECOVERY STRATEGIES
Phrase-level Recovery:-
• Perform local correction on the remaining input i.e. localize the
problem and then do error recovery.
• It’s a fast way for error recovery.
• Ex: A typical local correction is to replace a comma by a semicolon.
• Ex: Delete an extraneous semicolon and Insert a missing
semicolon.
ERROR RECOVERY STRATEGIES
Error Productions:-
• Add rules to grammar that describe the erroneous
syntax.
• It may resolve many, but not all potential errors.
• Good idea about common errors is found & their
appropriate solution is stored.
• These productions detect the anticipated errors
during parsing.
ERROR RECOVERY
STRATEGIES
Error Productions:-
• Ex: E→ +E | -E | *E | /E
• Here, the last two are error situations.
• Now, we change the grammar as:
E→ +E | -E | *A | /A
A→ E
• Hence, once it encounters *A, it sends an error
message asking the user if he is sure he wants to
use a unary “*”.
ERROR RECOVERY STRATEGIES
Global Correction:-
• Compiler to make as few changes as possible in
processing an incorrect input string.
• Given an incorrect input string x and grammar g,
algorithms will find a parse tree for a related string y,
such that the number of insertions, deletions, and
changes of tokens required to transform x into y is
as small as possible.
ERROR RECOVERY STRATEGIES
Global Correction:-
• It does the global analysis to find the errors.
• Expensive method & not practically used.
• Costly in terms of time & space.
THANK YOU

More Related Content

Similar to Error Detection & Recovery.pptx

System software module 4 presentation file
System software module 4 presentation fileSystem software module 4 presentation file
System software module 4 presentation filejithujithin657
 
Unit 3.1 Algorithm and Flowchart
Unit 3.1 Algorithm and FlowchartUnit 3.1 Algorithm and Flowchart
Unit 3.1 Algorithm and FlowchartBom Khati
 
Principles of Compiler Design
Principles of Compiler DesignPrinciples of Compiler Design
Principles of Compiler DesignMarimuthu M
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vbSalim M
 
Algorithmic problem sloving
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem slovingMani Kandan
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler ConstructionSarmad Ali
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing TechniquesAppili Vamsi Krishna
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptxssuser3b4934
 
Language Translator ( Compiler)
Language Translator ( Compiler)Language Translator ( Compiler)
Language Translator ( Compiler)Nazmul Hyder
 
Computer programing 111 lecture 2
Computer programing 111 lecture 2Computer programing 111 lecture 2
Computer programing 111 lecture 2ITNet
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and importiamluqman0403
 
Oracle PL/SQL exception handling
Oracle PL/SQL exception handlingOracle PL/SQL exception handling
Oracle PL/SQL exception handlingSmitha Padmanabhan
 
Compiler an overview
Compiler  an overviewCompiler  an overview
Compiler an overviewamudha arul
 
4_5802928814682016556.pptx
4_5802928814682016556.pptx4_5802928814682016556.pptx
4_5802928814682016556.pptxAshenafiGirma5
 
Cd ch1 - introduction
Cd   ch1 - introductionCd   ch1 - introduction
Cd ch1 - introductionmengistu23
 
CD - CH1 - Introduction to compiler design.pptx
CD - CH1 - Introduction to compiler design.pptxCD - CH1 - Introduction to compiler design.pptx
CD - CH1 - Introduction to compiler design.pptxZiyadMohammed17
 

Similar to Error Detection & Recovery.pptx (20)

System software module 4 presentation file
System software module 4 presentation fileSystem software module 4 presentation file
System software module 4 presentation file
 
Unit 3.1 Algorithm and Flowchart
Unit 3.1 Algorithm and FlowchartUnit 3.1 Algorithm and Flowchart
Unit 3.1 Algorithm and Flowchart
 
Principles of Compiler Design
Principles of Compiler DesignPrinciples of Compiler Design
Principles of Compiler Design
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vb
 
C programming
C programmingC programming
C programming
 
Algorithmic problem sloving
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem sloving
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing Techniques
 
Chapter 1.pptx
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptx
 
Language Translator ( Compiler)
Language Translator ( Compiler)Language Translator ( Compiler)
Language Translator ( Compiler)
 
Computer programing 111 lecture 2
Computer programing 111 lecture 2Computer programing 111 lecture 2
Computer programing 111 lecture 2
 
Cp 111 lecture 2
Cp 111 lecture 2Cp 111 lecture 2
Cp 111 lecture 2
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and import
 
Oracle PL/SQL exception handling
Oracle PL/SQL exception handlingOracle PL/SQL exception handling
Oracle PL/SQL exception handling
 
Compiler an overview
Compiler  an overviewCompiler  an overview
Compiler an overview
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
4_5802928814682016556.pptx
4_5802928814682016556.pptx4_5802928814682016556.pptx
4_5802928814682016556.pptx
 
Cd ch1 - introduction
Cd   ch1 - introductionCd   ch1 - introduction
Cd ch1 - introduction
 
CD - CH1 - Introduction to compiler design.pptx
CD - CH1 - Introduction to compiler design.pptxCD - CH1 - Introduction to compiler design.pptx
CD - CH1 - Introduction to compiler design.pptx
 

Recently uploaded

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 

Recently uploaded (20)

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 

Error Detection & Recovery.pptx

  • 1. Md Mohib Reg No- 20105124057 Branch- Computer Science & Engineering Semester- 6th ERROR DETECTION & RECOVERY
  • 2. ERROR HANDLING • It is an important feature of any compiler. • A good compiler should be able to detect and report errors. • It should be able to modify input, when it finds an error in lexical analysis phase. • A more sophisticated compiler should be able to correct the errors, by making guess of user intentions.
  • 3. ERROR HANDLING • The most important feature of error handler is correct and more centric error message. • It should following properties:- – Reporting errors in original source program, rather than intermediate or final code. – Error message shouldn’t be complicated. – Error message shouldn’t be duplicated. – Error message should localize the problem.
  • 4. SOURCES OF ERROR to meet the design may be • Algorithmic Errors:- – The algorithm used inadequate or incorrect. • Coding Errors:- – The programmer may introduce syntax or logical errors in implementing the algorithms.
  • 5. SOURCES OF ERROR • Lexical Phase:- – wrongly formed identifiers (or tokens). – Some character used which is undefined in PL. – Addition of an extra character. – Removal of a character that should be present. – Replacement of a character with an incorrect characters. – Transposition of 2 characters.
  • 6. SOURCES OF ERROR • Lexical Phase:- – Best way to handle a lexical error is to find the closest character sequence that does match a pattern (takes long time & unpractical) – Another way is to feed lexical analyzer – a list of legitimate token available to the error recovery routines. – Or generate an error.
  • 7. SOURCES OF ERROR • Syntactic:- – Comma instead of a semi-colon. – Misspelled keywords, operators. – Two expressions not connected by operator. – Null expression between parenthesis – Unbalanced parenthesis – Handle is absent • Usually, panic mode or phrase-level recovery is used.
  • 8. SOURCES OF ERROR • Semantic: Declaration and scope errors like use of undeclared or multi-declared identifiers, type mismatch, etc. In case of undeclared name, make an entry in the Symbol table & its attributes. Set a flag in ST that it was done due to an error rather than declaration.
  • 9. SOURCES OF ERROR • Logical: – Syntax is correct, but wrong logic applied to programmer. – Most difficult to recover. – Hard to detect by compiler.
  • 10. GOALS OF ERROR HANDLER meaningful • Detect errors quickly and produce diagnostic. • Detect subsequent errors after an error correction. • It shouldn’t slow down compilation.
  • 11. GOALS OF ERROR HANDLER Program submitted to a compiler often have errors of various kinds:- • So, good compiler should be able to detect as many errors as possible in various ways. • Even in the presence of errors, the compiler should scan the program and try to compile all of it.(error recovery).
  • 12. GOALS OF ERROR HANDLER • When the scanner or parser finds an error and cannot proceed ? • Then, the compiler must modify the input so that the correct portions of the program can be pieced together and successfully processed in the syntax analysis phase.
  • 13. CORRECTING COMPILER • These compilers does the job of error recovery not only from the compiler point of view but also from the programmers point of view. • Ex:PL/C • But, error recovery should not lead to misleading or spurious error messages elsewhere (error propagation).
  • 14. RUN-TIME ERRORS • Indication of run time errors is another neglected area in compiler design. • Because, code generated to monitor these violations increases the target program size, which leads to slow execution. • So these checks are included as “debugging options”.
  • 15. ERROR RECOVERY STRATEGIES There are four common error-recovery strategies that can be implemented in the parser to deal with errors in the code:- • Panic mode recovery • Phrase-level recovery • Error productions • Global correction
  • 16. ERROR RECOVERY STRATEGIES Panic Mode Recovery:- • Once an error is found, the parser intends to find designated set of synchronizing tokens (delimiters, semicolon or } ) by discarding input symbols one at a time. • When parser finds an error in the statement, it ignores the rest of the statement by not processing the input.
  • 17. ERROR RECOVERY STRATEGIES Panic Mode Recovery:- • This is the easiest way of error-recovery. • It prevents the parser from developing infinite loops. • Ex: a=b + c // no semi-colon • d=e + f ; • The compiler will discard all subsequent tokens till a semi-colon is encountered.
  • 18. ERROR RECOVERY STRATEGIES Phrase-level Recovery:- • Perform local correction on the remaining input i.e. localize the problem and then do error recovery. • It’s a fast way for error recovery. • Ex: A typical local correction is to replace a comma by a semicolon. • Ex: Delete an extraneous semicolon and Insert a missing semicolon.
  • 19. ERROR RECOVERY STRATEGIES Error Productions:- • Add rules to grammar that describe the erroneous syntax. • It may resolve many, but not all potential errors. • Good idea about common errors is found & their appropriate solution is stored. • These productions detect the anticipated errors during parsing.
  • 20. ERROR RECOVERY STRATEGIES Error Productions:- • Ex: E→ +E | -E | *E | /E • Here, the last two are error situations. • Now, we change the grammar as: E→ +E | -E | *A | /A A→ E • Hence, once it encounters *A, it sends an error message asking the user if he is sure he wants to use a unary “*”.
  • 21. ERROR RECOVERY STRATEGIES Global Correction:- • Compiler to make as few changes as possible in processing an incorrect input string. • Given an incorrect input string x and grammar g, algorithms will find a parse tree for a related string y, such that the number of insertions, deletions, and changes of tokens required to transform x into y is as small as possible.
  • 22. ERROR RECOVERY STRATEGIES Global Correction:- • It does the global analysis to find the errors. • Expensive method & not practically used. • Costly in terms of time & space.