Can I have an LL grammar for every deterministic context free language? - MathOverflow most recent 30 from http://mathoverflow.net2013-06-19T02:41:52Zhttp://mathoverflow.net/feeds/question/31733http://www.creativecommons.org/licenses/by-nc/2.5/rdfhttp://mathoverflow.net/questions/31733/can-i-have-an-ll-grammar-for-every-deterministic-context-free-languageCan I have an LL grammar for every deterministic context free language?lvella2010-07-13T16:36:13Z2010-07-13T19:17:28Z
<p>Every deterministic context free grammar can be represented by a LR(1) grammar, so this question can be rephrased as: can I build an equivalent LL(k) grammar from every LR(k) grammar? Can I have an example of deterministic context free language that can not have an LL(k) grammar?</p>
http://mathoverflow.net/questions/31733/can-i-have-an-ll-grammar-for-every-deterministic-context-free-language/31746#31746Answer by Antonio E. Porreca for Can I have an LL grammar for every deterministic context free language?Antonio E. Porreca2010-07-13T18:47:38Z2010-07-13T19:17:28Z<p>I’m not an expert on this topic, but I found these <a href="http://www.gdi.uni-bamberg.de/teaching/SS10/GdI-GTI-B/tomlect8.pdf" rel="nofollow">course notes</a> (including some bibliographical references) which state that the language <i>L</i> = {<i>x<sup>n</sup></i> : <i>n</i> ∈ ℕ} ∪ {<i>x<sup>n</sup>y<sup>n</sup></i> : <i>n</i> ∈ ℕ} has no LL(<i>k</i>) parser, while being deterministic context-free (see pp. 24 and 27).</p>
<p>Edit: I found a better reference. The paper <a href="http://www.cs.uwaterloo.ca/research/tr/1978/CS-78-24.pdf" rel="nofollow">Two iteration theorems for the LL(<i>k</i>) languages</a> by J.C. Beatty contains a proof that the LR language <i>L</i> = {<i>a<sup>n</sup>b<sup>n</sup></i>, <i>a<sup>n</sup>c<sup>n</sup></i> : <i>n</i> ≥ 1} is not LL (see Theorem 5.2).</p>