Which of the following features cannot be captured by context free grammars?
1994
Which of the following features cannot be captured by context free grammars?
- A.
Syntax of if–then–else statements
- B.
Syntax of recursive procedures
- C.
Whether a variable has been declared before its use
- D.
Variable names of arbitrary length
Attempted by 84 students.
Show answer & explanation
Correct answer: C
Context-free grammars define syntax rules like balanced parentheses or if-then-else structures. However, verifying variable declarations requires semantic analysis and symbol table tracking across scopes. This context-dependent check exceeds the capabilities of a pure context-free grammar.
A video solution is available for this question — log in and enroll to watch it.