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?

Answer: C. Whether a variable has been declared before its useContext-free grammars define syntax rules like balanced parentheses or if-then-else structures. However, verifying variable declarations requires semantic…

  1. A.

    Syntax of if–then–else statements

  2. B.

    Syntax of recursive procedures

  3. C.

    Whether a variable has been declared before its use

  4. D.

    Variable names of arbitrary length

Attempted by 184 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.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…