GATE / CS ARCHIVE

GATE CSE 2004 / QUESTION 8

Forbidden operator-grammar productions

Compiler Design · Parsing & Syntax Analysis · Full GATE CSE 2004 paper

GATE 2004, Q8 1 mark · MCQ
Report issue

Parsing & Syntax Analysis

Question 8, GATE 2004: P,Q,R are nonterminals and r,s,t are terminals. Which rules violate the requirements for an operator grammar? (i) P→QR; (ii) P→QsR; (iii) P→ε; (iv) P→QtRr.
Options:
(A) i only
(B) i and iii only
(C) ii and iii only
(D) iii and iv only
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. An operator grammar forbids adjacent nonterminals on a right-hand side and, in the standard definition used here, empty productions. P→QR violates the first rule and P→ε the second.

2. P→QsR and P→QtRr separate nonterminals by terminals. Thus i and iii, B.

3. Teaching check: A right-hand side can contain several nonterminals provided terminals separate adjacent ones. Thus QsR and QtRr are permitted. The empty-production restriction belongs to the conventional operator-grammar definition used here; do not confuse this syntactic test with conflict-free operator-precedence parsing.

Original paper, page 1