1. What is the main goal of panic mode error recovery in a compiler?
A) To automatically correct syntax errors
B) To allow the compiler to continue processing after detecting an error
C) To generate the final executable code
D) To perform semantic error detection
Answer: B) To allow the compiler to continue processing after detecting an error
2. Which of the following best describes panic mode recovery in a compiler?
A) The compiler attempts to correct the error automatically
B) The compiler skips over erroneous tokens until it reaches a known synchronization point
C) The compiler stops immediately when an error is detected
D) The compiler reports the error and terminates
Answer: B) The compiler skips over erroneous tokens until it reaches a known synchronization point
3. What is the main disadvantage of panic mode recovery?
A) It leads to more errors in the compiled program
B) It can result in loss of important error information and context
C) It makes the compilation process slower
D) It is more difficult to implement than other methods
Answer: B) It can result in loss of important error information and context
4. Which of the following recovery strategies is used in phrase-level recovery?
A) Skipping tokens until a synchronization point is found
B) Replacing erroneous tokens with syntactically correct ones
C) Correcting the entire program automatically
D) Analyzing the entire codebase to find all errors
Answer: B) Replacing erroneous tokens with syntactically correct ones
5. What is a key characteristic of phrase-level recovery in a compiler?
A) It requires the compiler to stop immediately when an error is detected
B) It replaces a small segment of the input program to restore correctness
C) It skips over sections of the program until the next valid construct is found
D) It attempts to recover from errors in larger blocks of code
Answer: B) It replaces a small segment of the input program to restore correctness
6. Which recovery technique is typically used in panic mode when a syntax error occurs?
A) Skipping tokens until a semicolon is found
B) Rewriting the entire program
C) Generating a warning but continuing the parsing process
D) Rebuilding the entire parse tree
Answer: A) Skipping tokens until a semicolon is found
7. In phrase-level recovery, what action does the compiler take to recover from an error?
A) It replaces the erroneous token with a valid token based on syntax rules
B) It terminates the compilation immediately
C) It generates machine code without error checking
D) It runs the program to detect runtime errors
Answer: A) It replaces the erroneous token with a valid token based on syntax rules
8. Which of the following is a benefit of panic mode recovery?
A) It allows the parser to continue after encountering an error, making it efficient for handling multiple errors
B) It provides the best accuracy in error detection and correction
C) It can recover from semantic errors
D) It is capable of fixing errors automatically without human intervention
Answer: A) It allows the parser to continue after encountering an error, making it efficient for handling multiple errors
9. Which of the following synchronization points are commonly used in panic mode recovery?
A) End of statement, closing braces, semicolons
B) Function return types
C) Variable declarations
D) Expressions involving operators
Answer: A) End of statement, closing braces, semicolons
10. When is phrase-level recovery most useful in error handling?
A) When the program is structurally complex and needs significant corrections
B) When only minor, localized errors need to be fixed to continue parsing
C) When the program contains semantic errors that cannot be corrected
D) When the compiler is unable to recover from an error using other strategies
Answer: B) When only minor, localized errors need to be fixed to continue parsing
11. What is a typical limitation of phrase-level recovery?
A) It is only applicable for semantic errors
B) It is unable to handle errors in large blocks of code
C) It might not handle larger syntax errors effectively
D) It is more complex and slower compared to panic mode recovery
Answer: C) It might not handle larger syntax errors effectively
12. Which recovery strategy can be combined with panic mode recovery to achieve better error handling in compilers?
A) Backtracking
B) Phrase-level recovery
C) Error-directed parsing
D) Code generation
Answer: B) Phrase-level recovery
13. In the context of panic mode recovery, what happens if the synchronization point is not found immediately?
A) The compiler stops processing further code
B) The compiler continues searching for a synchronization point
C) The error is automatically corrected
D) The program runs with limited functionality
Answer: B) The compiler continues searching for a synchronization point
14. Which of the following statements is true about phrase-level recovery?
A) It works by ignoring the error and continuing the parsing process
B) It replaces erroneous input with valid alternatives to restore parsing
C) It skips the entire statement or block containing the error
D) It can only be used in lexical analysis
Answer: B) It replaces erroneous input with valid alternatives to restore parsing
15. In panic mode recovery, how does the compiler typically decide which token to skip after encountering an error?
A) It uses predefined synchronization points to identify where to resume parsing
B) It randomly selects a token to skip
C) It attempts to backtrack and analyze the syntax again
D) It ignores all errors and proceeds with the parsing
Answer: A) It uses predefined synchronization points to identify where to resume parsing
16. In the context of error recovery, what does the term “synchronization point” refer to?
A) A specific point in the program where the compiler tries to restart after an error
B) The location of a function definition
C) A place where no errors are allowed to occur
D) A region of the program that contains only comments
Answer: A) A specific point in the program where the compiler tries to restart after an error
17. Which of the following is a primary disadvantage of phrase-level recovery?
A) It cannot be used to handle syntax errors
B) It can only be used for very specific types of errors
C) It may not detect all types of errors in a program
D) It is computationally expensive
Answer: B) It can only be used for very specific types of errors
18. In panic mode recovery, what is the usual goal of skipping tokens?
A) To generate the correct output code immediately
B) To recover from a small syntax error and continue parsing
C) To find the most optimal solution for the error
D) To discard all errors and continue compilation
Answer: B) To recover from a small syntax error and continue parsing