Which of the following grammars are operator grammar? Where E, F, T are…

2022

Which of the following grammars are operator grammar? Where E, F, T are non-terminals and +, -, i, d, ε are terminal symbols. G₁: E → E+T | T   T → T*F | F   F → i | d G₂: E → E+T | T   T → T*F | F   F → i | d | ε G₃: E → E+T | T   T → T*F | F | ε   F → i | d G₄: E → E+T | T   T → F   F → i | d | F * i | ε

  1. A.

    G₁, G₂

  2. B.

    G₁, G₃, G₅

  3. C.

    G₁, G₃, G₄

  4. D.

    None of these

Attempted by 119 students.

Show answer & explanation

Correct answer: D

Definition: An operator-precedence (operator) grammar must not have ε-productions and must not contain two adjacent nonterminals on the right-hand side of any production. These restrictions ensure well-defined operator-precedence relations.

  • No ε-productions (no production whose right-hand side is ε).

  • No two adjacent nonterminals on any right-hand side.

Check each grammar against these rules:

  • G₁: E → E+T | T; T → T*F | F; F → i | d.

    No ε-productions and every pair of nonterminals is separated by an operator, so G₁ satisfies the operator-grammar conditions.

  • G₂: same as G₁ but F → i | d | ε.

    Contains an ε-production (F → ε), which disqualifies it as an operator grammar.

  • G₃: E → E+T | T; T → T*F | F | ε; F → i | d.

    Contains an ε-production (T → ε), so G₃ is not an operator grammar.

  • G₄: E → E+T | T; T → F; F → i | d | F * i | ε.

    Includes an ε-production (F → ε), so G₄ is not an operator grammar.

Conclusion: Only G₁ meets the operator-grammar requirements. Because none of the provided answer choices lists only G₁, the correct choice among the given options is 'None of these'.

Explore the full course: Niacl Ao It Specialist