• edited by
16,496 views
31 31 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 \: \varepsilon$

  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

3 Answers

Best answer
53 53 votes

answer is B.

Operator grammar  cannot contain  

  1. Nullable variable  
  2. Two adjacent non-terminal on $\text{RHS}$ of production
• edited by
14 14 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
0 0 votes

A grammar is an Operator Grammar if and only if its productions satisfy two mandatory conditions:

  1. No $\epsilon$-productions: No production has an empty right-hand side ($A \rightarrow \epsilon$).

  2. No adjacent non-terminals: No two non-terminals appear side-by-side on the right-hand side (e.g., $A \rightarrow \dots BC \dots$ is forbidden).

Rules (I) and (III) violate the requirements.

B. (I) and (III) only

 

Answer:
Position:
Show:

Related questions

33 33 votes
3 answers 3 answers
13.1k
13.1k views
Kathleen asked Sep 18, 2014
13,138 views
Consider the following grammar G:$S \rightarrow bS \mid aA \mid b$$A \rightarrow bA \mid aB$$B \rightarrow bB \mid aS \mid a$Let $N_a(w)$ and $N_b(w)$ denote the number o...
41 41 votes
2 answers 2 answers
17.0k
17.0k views
Kathleen asked Sep 18, 2014
17,022 views
Consider the grammar with the following translation rules and $E$ as the start symbol$$\begin{array}{lll}E \rightarrow E_ 1\# \: T & \qquad\left\{E.value = E_1.value * ...
62 62 votes
5 answers 5 answers
21.2k
21.2k views
Vikrant Singh asked Nov 12, 2014
21,179 views
Consider the grammar rule $E \rightarrow E1 – E2$ for arith­metic expressions. The code generated is targeted to a CPU having a single user register. The sub­traction ope...
36 36 votes
2 answers 2 answers
9.7k
9.7k views
Kathleen asked Sep 18, 2014
9,731 views
Consider a program $P$ that consists of two source modules $M_1$ and $M_2$ contained in two different files. If $M_1$ contains a reference to a function defined in $M_2$ ...