523 views

1 Answer

0 0 votes

An LL(k) grammar is a context-free grammar that can be parsed by an LL(k) parser, which reads input from left to right, performs leftmost derivations, and uses k tokens of lookahead to make parsing decisions.

To determine whether a given context-free grammar G is an LL(k) grammar, you can use the following algorithm:

  1. First, determine the leftmost derivation of G for a given input string. A leftmost derivation is a parse tree in which the leftmost non-terminal is expanded at each step.

  2. Next, construct the predictive parse table for G, which specifies the production rule to be used for each non-terminal based on the next k tokens of input.

  3. Check if the predictive parse table for G is consistent with the leftmost derivation of G. This means that the production rule chosen by the parse table at each step of the leftmost derivation must be the same as the one actually used in the leftmost derivation.

  4. If the predictive parse table is consistent with the leftmost derivation, then G is an LL(k) grammar. Otherwise, it is not.

Note that this algorithm only works for context-free grammars in Greibach normal form, as the predictive parse table can only be constructed for this type of grammar.

 

Position:
Show:

Related questions

0 0 votes
0 0 answers
620
620 views
Naveen Kumar 3 asked Jun 25, 2019
620 views
Give LL grammars for the following languages, assuming $Σ =$ {$a,b, c$}.(i) $L=$ {$a^nb^mc^{n+m}:n\geq0,m\geq0$} .(ii) $L=$ {$a^{n+2}b^mc^{n+m}:n\geq0,m\geq0$} .(iii) $L=...
0 0 votes
0 0 answers
442
442 views
Naveen Kumar 3 asked Jun 25, 2019
442 views
Show that if G is an LL (k) grammar, then L (G) is a deterministic context-free language.
0 0 votes
0 0 answers
381
381 views
0 0 votes
1 1 answer
516
516 views