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?

  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 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.

Explore the full course: Gate Guidance By Sanchit Sir