Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>An <code>LL(k)</code> grammar is one that allows the construction of a deterministic, descent parser with only <code>k</code> symbols of lookahead. The problem with left recursion is that it makes it impossible to determine which rule to apply until the complete input string is examined, which makes the required <code>k</code> potentially infinite.</p> <p>Using your example, choose a <code>k</code>, and give the parser an input sequence of length <code>n &gt;= k</code>:</p> <pre><code>aaaaaaa... </code></pre> <p>A parser cannot decide if it should apply <code>S-&gt;SA</code> or <code>S-&gt;empty</code> by looking at the <code>k</code> symbols ahead because the decision would depend on how many times <code>S-&gt;SA</code> has been chosen before, and that is information the parser does not have. </p> <p>The parser would have to choose <code>S-&gt;SA</code> exactly <code>n</code> times and <code>S-&gt;empty</code> once, and it's impossible to decide which is right by looking at the first <code>k</code> symbols in the input stream. </p> <p>To know, a parser would have to both examine the complete input sequence, and keep count of how many times <code>S-&gt;SA</code> has been chosen, but such a parser would fall outside of the definition of <code>LL(k)</code>.</p> <p>Note that unlimited lookahead is not a solution because a parser runs on limited resources, so there will always be a finite input sequence of a length large enough to make the parser crash before producing any output.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload