title: LR(1) Item DFA - Computing Lookaheads
body: <p>I have trouble understanding how to compute the lookaheads for the LR(1)-items.</p>
  
  <p>Lets say that I have this grammar:</p>
  
  <pre><code>S -&gt; AB
  A -&gt; aAb | a
  B -&gt; d
  </code></pre>
  
  <p>A LR(1)-item is an LR(0) item with a lookahead. So we will get the following LR(0)-item for state 0:</p>
  
  <pre><code>S -&gt; .AB , {lookahead} 
  A -&gt; .aAb,  {lookahead} 
  A -&gt; .a,  {lookahead}
  </code></pre>
  
  <p>State: 1 </p>
  
  <pre><code>A -&gt;  a.Ab, {lookahead} 
  A -&gt;  a. ,{lookahead} 
  A -&gt; .aAb ,{lookahead} 
  A -&gt;.a ,{lookahead}
  </code></pre>
  
  <p>Can somebody explain how to compute the lookaheads ? What is the general approach ?</p>
  
  <p>Thank you in advance </p>