in Compiler Design
2,266 views
5 votes
5 votes

Which of the following is TRUE regarding LL(0) grammar?

  1. We can have a LL(0) grammar for any regular language
  2. We can have a LL(0) grammar for a regular language only if it does not contain empty string
  3. We can have a LL(0) grammar for any regular language if and only if it has prefix property
  4. We can have a LL(0) grammar for only single string languages
in Compiler Design
by
2.3k views

5 Comments

@Arjun sir, i think the answer is D.

LL(0) means the grammar which can be generated with 0 look-a-heads.

So we have to generate a string even without looking at the first production symbol. this is only possible if there is only 1 string that the grammar can generate.

example:

S -> abc

now to generate the language of the grammar we need not even look at the sarting symbol 'a', because the only string it can generate is 'abc'

 

9
9
Yes. Or no string also. That is why we don't have a real LL(0) parser :)
3
3
sir, please explain point no 3 for both LL(o) and LL(1) grammar.
1
1

@OneZero  Can you explain option C or any article where I can read more about prefix property ?

only if it has prefix property

Did you discarded it because if a grammer has same prefix and there is no disjoint it won't be LL(1)?

0
0

@OneZero for LL(0) , 0 look-aheads

S->abc or S->epsilon 

Here null atring also be there

@Arjun sir, am i right ?

0
0

1 Answer

5 votes
5 votes

LL(0) grammars have no lookahead. And since they follow Leftmost derivation, at each step the parser has to derive the string by seeing 0 symbols. => Parser sees nothing.

So whenever we have multiple choices for any Variable in the grammar, LL(0) fails.

Hence, LL(0) parser can only parse grammars that strictly generate one single string.

Option D

Answer:

Related questions