in Compiler Design edited by
183 views
0 votes
0 votes

A single production is a production whose body is a single nonterminal, i.e., a production of the form $A\rightarrow A$.

  1. Give an algorithm to convert any grammar into an $\epsilon$-free grammar, with no single productions, that generates the same language (with the possible exception of the empty string) Hint: First eliminate $\epsilon$-productions, and then find for which pairs of nonterminals $A$ and $B$ does $A\overset{\ast}{\Rightarrow}B$ by a sequence of single productions. 
  2. Apply your algorithm to the grammar 

$$E\rightarrow E+T\mid T$$

$$T\rightarrow T\ast F\mid F$$

$$F\rightarrow (E)\mid id$$

  1. Show that, as a consequence of part $(a)$, we can convert a grammar into an equivalent grammar that has no cycles (derivations of one or more steps in which $A\overset{\ast}{\Rightarrow}A$ for some nonterminal $A$).  
in Compiler Design edited by
by
183 views

Please log in or register to answer this question.

Related questions