title: Removing hidden ambiguity in grammar using left factoring
body: <p>I am trying to reduce the grammar to LL(1) for a hypothetical language we created. I have removed most of the left factoring issues in the grammar, using the general rule of introducing new non-terminal characters for the same.</p>
  
  <p>For example,</p>
  
  <pre><code>&lt;assignmentstats&gt;------- &lt;type&gt;&lt;id&gt;=&lt;E&gt;/ id=&lt;E&gt;/id'['&lt;E&gt;']'=&lt;E&gt;/     
  </code></pre>
  
  <p>is transformed to</p>
  
  <pre><code>&lt;assignmentstats&gt;------- &lt;type&gt;&lt;id&gt;=&lt;E&gt;/ id&lt;LF3&gt;
  &lt;LF3&gt;------- =&lt;E&gt;/[&lt;E&gt;]=&lt;E&gt;
  </code></pre>
  
  <p>After applying such rules for all the required statements, I expected an unambiguous grammar.</p>
  
  <p>But the following statement is somehow still ambiguous.</p>
  
  <pre><code>&lt;body&gt;------- &lt;forrelatedstuff&gt;/ &lt;floors&gt;/&lt;stats&gt; 
  </code></pre>
  
  <p>Here are the related statements of the grammar(only those required has been shown)</p>
  
  <pre><code>&lt;funcbody&gt;----- {&lt;stats&gt;}    
  &lt;stats&gt;----- &lt;stat&gt; &lt;stats&gt;/ #       
  &lt;floors&gt;-------- &lt;floor&gt;&lt;floors&gt;/ #     
  &lt;floor&gt;------- floo &lt;id&gt;&lt;arr&gt;{stats}/id&lt;arr&gt;{&lt;stats&gt;}     
  &lt;stat&gt;----- &lt;superstats&gt;/&lt;returnstats&gt;
  &lt;superstats&gt;----- &lt;type&gt;id&lt;Zip&gt;/id&lt;LF3&gt;  
  &lt;building&gt; ------- build &lt;id&gt; {&lt;body&gt;}   
  &lt;returnstats&gt;--------- return &lt;E&gt;  
  </code></pre>
  
  <p>I looked more into it , and found that the ambiguity is between 'floors' and 'stats'. The FIRST('stats') and FIRST('floors'), i.e. the set of first terminal characters contain 'id' and '}' for both.</p>
  
  <p>I can see why this would be a problem and how left factoring could solve this.But how can I remove such kind of ambiguity through left factoring?</p>
  
  <p>Note: Here, 
  'id' denotes an identifier.</p>
  
  <p>'#' denotes epsilon.</p>