title: Parsing table for LL1 grammar
body: <p>I have to produce an LL1 grammar that covers the IF, IF-ELSE, IF - ELSE IF - ELSE condition for a C program. I was doing the parsing table and in the AUX_PROG rule I obtain two entries for the same terminal ( &quot;}&quot;, &quot;)&quot; ), meaning that the grammar isn't LL(1).</p>
  <p>Can you tell me what can I change in order to get it right?</p>
  <p>This is my grammar with also the first and the follows:</p>
  <pre><code>&lt;MAIN&gt; ::= int main () { &lt;AUX_PROG&gt; }
  &lt;AUX_PROG&gt; ::= &lt;PROG&gt; &lt;AUX_PROG&gt;
  | ε
  &lt;PROG&gt; ::= &lt;IF_STAT&gt;
  | &lt;AUX_OTHER&gt;
  &lt;IF_STAT&gt; ::= if (&lt;AUX_OTHER&gt;) {&lt;AUX_PROG&gt;} &lt;ELSE_STAT&gt;
  &lt;AUX_OTHER&gt; ::= other &lt;AUX_OTHER&gt;
  | ( &lt;AUX_PROG&gt; ) &lt;AUX_OTHER&gt;
  | { &lt;AUX_PROG&gt; } &lt;AUX_OTHER&gt;
  | &lt;KEYWORD&gt; &lt;AUX_OTHER&gt;
  | ε
  &lt;ELSE_STAT&gt; ::= else &lt;AUX_ELSE_STAT&gt;
  | ε
  &lt;AUX_ELSE_STAT&gt; ::= { &lt;AUX_PROG&gt; }
  | if (&lt;AUX_OTHER&gt;) {&lt;AUX_PROG&gt;} else &lt;AUX_ELSE_STAT&gt;
  &lt;KEYWORD&gt; ::= int
  | main
  
  
  
  follow(AUX_OTHER) ={)} U follow(PROG) = {if, other, (, {, int, main,&quot;}&quot;, )}
  follow(ELSE_STAT) = follow(IF_STAT) = {if, other, (, {, int, main,&quot;}&quot;, )}
  follow(IF_STAT) = follow(PROG) = {if, other, (, {, int, main,&quot;}&quot;, )}
  follow(PROG) = (first(AUX_PROG) - ε) U follow(AUX_PROG) = {if, other, (, {, int, main,&quot;}&quot;, )}
  follow(AUX_PROG) = {&quot;}&quot;, )}
  follow(MAIN) = {$}
  follow(AUX_ELSE_STAT) = follow(ELSE_STAT) = {if, other, (, {, int, main,&quot;}&quot;, )}
  follow(KEYWORD) = (first(AUX_OTHER) - ε) U follow(AUX_OTHER) = {other, (, {, int, main, if,&quot;}&quot;, )}
  
  
  
  first(MAIN) = {int}
  first(AUX_PROG) = {if, other, (, {, int, main, ε}
  first(PROG) = {if, other, (, {, int, main, ε}
  first(IF_STAT) = {if}
  first(ELSE_STAT) = {else, ε}
  first(AUX_ELSE_STAT) ={ &quot;{&quot;, if }
  first(AUX_OTHER) = {other, (, {, int, main, ε}
  first(KEYWORD) = {int, main}
  </code></pre>
  <p>UPDATE:</p>
  <p>I have also tried to change the AUX_OTHER production to remove that ε element but it also gives me double entries in the parsing table.</p>
  <pre><code>&lt;AUX_OTHER&gt; ::= other &lt;AUX_PROG&gt;
  | ( &lt;AUX_PROG&gt; ) &lt;AUX_PROG&gt;
  | { &lt;AUX_PROG&gt; } &lt;AUX_PROG&gt;
  | &lt;KEYWORD&gt; &lt;AUX_PROG&gt;
  </code></pre>