title: Building LR(1) configuration lookahead
body: <p>I really have some troubles to cauculate the lookahead when building the LR(1) item sets, i had tried some lecture notes form different sites, but still...
  My example is </p>
  
  <pre>
  S -> E + S | E
  E -> num | ( S )
  </pre>
  
  <p>The item set is</p>
  
  <pre>
  I0:
  S’ -> . S       $
  S -> . E + S    $
  S -> . E        $
  E -> . num      +,$
  E -> . ( S )    +,$
  
  I1:
  S ->E .+ S      $
  S ->E .         $
  </pre>
  
  <p>The first item in set I0 </p>
  
  <pre>S’ -> . S     $</pre>
  
  <p>is initialization.</p>
  
  <p>The second item in set I0</p>
  
  <pre>S -> . E + S     $</pre>
  
  <p>means there is nothing on stack, we expect to read E+S, then reduce iff the token after E+S is  $.</p>
  
  <p>The third item in set I0</p>
  
  <pre>S -> . E        $</pre>
  
  <p>means that we expect to read E and reduce iff the token after E is $.</p>
  
  <p>Then i am confused about the fouth item in set I0,</p>
  
  <pre>E -> . num      +,$</pre>
  
  <p>I have no ideas why there are + and $ tokens.</p>
  
  <p>and if anyone can explain this for me in plain English please.
  <b>
  For each configuration [A –> u•Bv, a] in I, for each production B –> w in G', and for
  each terminal b in First(va) such that [B –> •w, b] is not in I: add [B –> •w, b] to I.
  </b></p>
  
  <p>Thanks!!!</p>