COMPILER DESIGN

SYNTAX ANALYSIS

ROLE OF THE PARSER

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What type of conflicts can occur in the shift-reduce parsing?
A
reduce/reduce
B
shift/reduce
C
Both shift/reduce and reduce/reduce
D
None of the above
Explanation: 

Detailed explanation-1: -In shift-reduce parsing, there is two types of conflicts: one is shift-reduce conflict (SR conflict) and another is reduce – reduce conflict (RR) conflict.

Detailed explanation-2: -Shift Reduce Parser is a type of Bottom-Up Parser. It generates the Parse Tree from Leaves to the Root. In Shift Reduce Parser, the input string will be reduced to the starting symbol. This reduction can be produced by handling the rightmost derivation in reverse, i.e., from starting symbol to the input string.

Detailed explanation-3: -Overview. The Shift-Reduce Conflict is the most common type of conflict found in grammars. It is caused when the grammar allows a rule to be reduced for particular token, but, at the same time, allowing another rule to be shifted for that same token.

Detailed explanation-4: -There are two types of conflics we might encounter: shift-reduce and reduce-reduce: Shift-reduce conflict. This occurs when the parser is faced with a choice of a shift action and a reduce action. (Yacc’s default action in the case of a shift-reduce conflict is to choose the shift action.)

Detailed explanation-5: -Shift just means 1 thing, you advance the input stream, so there cannot be a shift-shift conflict.

There is 1 question to complete.