title: How to parse this simple grammar? Is it ambiguous?
body: <p>I'm delving deeper into parsing and came across an issue I don't quite understand. I made up the following grammar:</p>
  
  <pre><code>S = R | aSc
  R = b | RbR
  </code></pre>
  
  <p>where S is the start symbol. It is possible to show that abbbc is a valid sentence based on this grammar, hopefully, that is correct but I may have completely missunderstood something. If I try to implement this using recursive descent I seem to have a problem when trying to parse abbbc, using left-derivation eg</p>
  
  <pre><code>S =&gt; aSc
  aSc =&gt; aRc
  </code></pre>
  
  <p>at this point I would have thought that recursive descent would pick the first option in the second production because the next token is b leading to:</p>
  
  <pre><code> aRc =&gt; abc
  </code></pre>
  
  <p>and we're finished since there are no more non-terminals, which isn't of course abbbc. The only way to show that abbbc is valid is to pick the second option but with one lookahead I assume it would always pick b. I don't think the grammar is ambiguous unless I missed something. So what I am doing wrong?</p>
  
  <p><strong>Update:</strong> I came across this nice derivation app at <a href="https://web.stanford.edu/class/archive/cs/cs103/cs103.1156/tools/cfg/" rel="nofollow noreferrer">https://web.stanford.edu/class/archive/cs/cs103/cs103.1156/tools/cfg/</a>. I used to do a sanity check that abbbc is a valid sentence and it is. </p>
  
  <p>Thinking more about this problem, is it true to say that I can't use LL(1) to parse this grammar but in fact need LL(2)? With two lookaheads I could correctly pick the second option in the second production because I now also know there are more tokens to be read and therefore picking b would prematurely terminate the derivation.</p>