2 votes 2 votes Check whether this grammar is LL(1) or not? Compiler Design compiler-design parsing + – The Technical Guy asked Jan 4, 2018 • edited Jan 4, 2018 by The Technical Guy The Technical Guy 1.0k views answer comment Share Follow See all 3 Comments See all 3 3 Comments reply The Technical Guy commented Jan 5, 2018 reply Follow Share 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 votes 0 votes LeenSharma commented Jan 5, 2018 reply Follow Share got my mistake. 0 votes 0 votes Manu Thakur commented Jan 5, 2018 i edited by Manu Thakur Jan 5, 2018 reply Follow Share 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 votes 0 votes Please log in or register to add a comment.
Best answer 1 votes 1 votes Plz go through this solution.... Manis answered Jan 5, 2018 • selected Jan 6, 2018 by The Technical Guy Manis comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes This grammar is not LL(1) as first of both non-terminals A and B are same asharani97 answered Jan 5, 2018 asharani97 comment Share Follow See 1 comment See all 1 1 comment reply The Technical Guy commented Jan 5, 2018 reply Follow Share 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 votes 0 votes Please log in or register to add a comment.
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) Sandeep Suri answered Jan 8, 2018 Sandeep Suri comment Share Follow See all 0 reply Please log in or register to add a comment.