in Compiler Design edited by
979 views
2 votes
2 votes

Check whether this grammar is LL(1) or not?

in Compiler Design edited by
979 views

3 Comments

you are legend bro. How this grammar can be ambiguous. This grammar can produce only two strings one is ab and the second is ba.
0
0
got my mistake.
0
0
edited by

This grammar is $LL(1)$. A and B have single - single productions, so no need to even check for A and B.

And regarding the variable S, $FIRST(AaAb)$  ∩ $FIRST(BbBa) = phi$

Hence, this grammar is LL(1).

No, need to even check for LL(1) properties, if you look at the grammar, there are only two strings in it, 'ab' and 'ba', one string starts with 'a' and second string starts with 'b', hence no ambiguity, by looking at the first input element parser can know, that which production to choose.

0
0

3 Answers

1 vote
1 vote
Best answer

Plz go through this solution....

selected by
by
0 votes
0 votes
This grammar is not LL(1) as first of both non-terminals A and B are same

1 comment

I think it's an LL(1) grammar because we check the first of RHS, not the first of A and B. So if I put epsilon in RHS then I get a and b for the second production.
0
0
0 votes
0 votes
The above Grammar is LL(1) only perform intersection of first(AaAb) and first(BbBa). It will result in phi ie a intersection b phi.. hence Grammar is LL(1)