edited by
184 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$).  
edited by

Please log in or register to answer this question.

Related questions

0 votes
0 votes
1 answer
4
admin asked Aug 20, 2019
762 views
Show that the following grammar$S\rightarrow Aa\mid bAc\mid Bc\mid bBa$$A\rightarrow d$$B\rightarrow d$is LR(1) but not LALR(1).