Questions: Syntax Error Recovery Techniques

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A parser using panic-mode recovery encounters a missing semicolon inside a nested function body. Which of the following most accurately describes what happens?

AThe parser terminates immediately and reports a single error message about the missing semicolon
BThe parser automatically inserts the missing semicolon and continues without reporting any error
CThe parser discards input tokens until it reaches a synchronization token (e.g., semicolon or closing brace), reports the error, then resumes parsing
DThe parser backtracks to the beginning of the function and re-parses using an alternative grammar rule
Question 2 Multiple Choice

A student argues: 'With a sufficiently sophisticated ML model trained on millions of programs, a compiler could always determine exactly what the programmer intended and automatically fix any syntax error.' What is the fundamental problem with this claim?

AMachine learning inference is too computationally slow to run at compile time
BProgrammer intent is not encoded in the syntax — multiple repairs may be syntactically valid, and no algorithm can reliably determine which matches the programmer's meaning
CModern compilers already do this with AI-assisted recovery, making the claim true in practice
DSuch a system would work well but would incorrectly modify valid programs by treating unusual-but-correct code as errors
Question 3 True / False

After panic-mode error recovery, a practical compiler should suppress error messages for the next few tokens, because errors reported immediately following recovery are likely to be spurious cascades of the original mistake.

TTrue
FFalse
Question 4 True / False

Simpler error recovery strategies like panic mode are generally inferior to sophisticated phrase-level repairs (token insertion, deletion, replacement) because they discard more input and lose more syntactic context.

TTrue
FFalse
Question 5 Short Answer

Why is syntax error recovery in compilers described as 'inherently heuristic,' and what is the practical measure of a good recovery strategy?

Think about your answer, then reveal below.