COMPILER DESIGN

TOOLS AND TECHNIQUES FOR COMPILER DESIGN

MISCELLENOUS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which of the follwing statement is True for LALR parser
A
It detect recursion and remove it
B
It detect left factoring and remove it
C
It resolve Reduce-reduce conflict only
D
It resolve Shif-reduce and reduce-reduce conflict
Explanation: 

Detailed explanation-1: -” A shift reduce conflict occurs in an LR(1) parser if and only if there exist items: A-> alpha . such that Follow(A) is not disjoint from First(beta). where A is a non-terminal, alpha and beta are possibly empty sequences of grammar symbols."

Detailed explanation-2: -LALR(1) parser for a grammar, G can have shift-reduce ( S-R) conflicts if and only if there is a S-R conflict in its immediate sub-parsers (e.g. LR(1)). If LR(0) has S-R conflicts then they may get removed in LR (1), hence there will be no S-R conflict in LALR(1).

Detailed explanation-3: -LALR stands for look ahead left right. It is a technique for deciding when reductions have to be made in shift/reduce parsing. Often, it can make the decisions without using a look ahead. Sometimes, a look ahead of 1 is required. Most parser generators (and in particular Bison and Yacc) construct LALR parsers.

There is 1 question to complete.