2 votes 2 votes if a grammar is CLR(1) with no mergeable states, then it is LALR(1) ? I suppose it is “yes”, am I right? Compiler Design compiler-design parsing + – s_dr_13 asked Jan 3, 2022 s_dr_13 499 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 4 votes 4 votes In LALR(1) we merge states of CLR(1) if they have same reduction but different lookaheads. So if there is no mergeable states in CLR(1) then it is also LALR(1). Isha_99 answered Jan 3, 2022 • selected Jan 3, 2022 by s_dr_13 Isha_99 comment Share Follow See all 3 Comments See all 3 3 Comments reply ankit3009 commented Jan 3, 2022 reply Follow Share Having different lookaheads is not compulsory, right? It may or may not have different lookaheads, is this statement correct? 0 votes 0 votes Isha_99 commented Jan 3, 2022 reply Follow Share If same productions have same lookaheads then why they will be in different states in CLR(1) ? In CLR(1) we generally get more states because same productions but different lookaheads are kept in different states , and we merge such states in LALR(1). 2 votes 2 votes ankit3009 commented Jan 4, 2022 reply Follow Share Yes, agreed. 2 votes 2 votes Please log in or register to add a comment.
0 votes 0 votes Just to add a few points, If a grammar is not CLR(1) then it is definitely not LALR(1). If a grammar is CLR(1), it may or may not be LALR(1) always. dhruvak23 answered Mar 7, 2022 dhruvak23 comment Share Follow See all 0 reply Please log in or register to add a comment.