Machine-translated by Google. Questions are authored in English.
Top

Discussion

Consider the grammar shown below

\(S \rightarrow AA\)
\(A \rightarrow aA / d\)

The grammar is :

  • A.LL(1)
  • B.SLR(1) but not LL(1)
  • C.LALR(1) but not SLR(1)
  • D.LR(1) but not LALR(1)

Answer: A

The grammar is LL(1).

A grammar is LL(1) if, for each non-terminal, the alternatives can be told apart by one symbol of lookahead. S has a single production. For A → aA | d, the alternatives begin with different terminals: FIRST(aA) = {a} and FIRST(d) = {d}, which are disjoint, and neither alternative derives the empty string, so no FOLLOW set is involved.

Every LL(1) grammar without such conflicts is also SLR(1), LALR(1) and LR(1), so the options that say 'but not LL(1)' are all false for this grammar.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.