The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+9 votes

Which of the following grammar rules violate the requirements of an operator grammar? P, Q, R are nonterminals, and r, s, t are terminals.

  1. P $\rightarrow$ Q R

  2. P $\rightarrow$ Q s R

  3. P $\rightarrow \: ε$

  4. P $\rightarrow$ Q t R r

  1. (I) only
  2. (I) and (III) only
  3. (II) and (III) only
  4. (III) and (IV) only
asked in Compiler Design by Veteran (59.5k points) | 1.8k views

2 Answers

+22 votes
Best answer

answer is B.

Operator grammar  cannot contain  

  1. Nullable variable  
  2. Two adjacent non-terminal on $\text{RHS}$ of production
answered by (233 points)
edited by
+8 votes
(I) P --> QR is not possible since two Non Terminal  should include one operator as Terminal.
(II) Correct
(III)  incorrect.
(IV) Correct.

so I and III violate the requirements of an operator grammar.

Hence (B) is correct option
answered by Veteran (67.8k points)
is PQ-->RsT is operator grammar or not?

no, PQ-->RsT will also not be in operator grammer, because

PQ is present in LHS means it has also been generated by some production like V ---> αPQβ which is also in grammer and voilating operator precedence condition..

No, PQ-> RsT is not context free, so it cant be operator grammar.

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

37,998 questions
45,495 answers
48,629 users