The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+13 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 (52.1k points) | 2.3k views

2 Answers

+27 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
+10 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 (68.9k 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.


Not able to understand ur above comment ..

is this right reasoning

PQ -> Rst not CFG hence not 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
49,811 questions
54,540 answers
75,603 users