World's most popular travel blog for travel bloggers.

Is there any way to distinguish between LL(k) and LR(k) grammar?

, , No Comments
Problem Detail: 

I am recently studying about Compilers designing. I came to know about two types of grammar one is LL grammar and other is LR grammar.

We also know the facts that every LL grammar is LR that is LL grammar is a proper subset of LR grammar. First one is used in top-down parsing and the second one is used in bottom-up parsing.

But is there any way to so that we can say that a given grammar is LL or LR?

Asked By : Deb

Answered By : Deb

We have to check only that a grammar is LL or not because every LL grammar is LR that is LL is proper subset of LR. So if a grammar is LL then it must be LR but every LR is not LL.

A grammar G is in LL iff whenever A->C|D , the following condition should hold:

  1. First(C) and First(D) are disjoint sets.
  2. If empty is in First(D) the First(C) and Follow(A) are disjoint sets likewise empty is in First(C).
Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/4888

0 comments:

Post a Comment

Let us know your responses and feedback