COMPUTER SCIENCE AND ENGINEERING
COMPILER DESIGN
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Unambiguous
|
|
Regular
|
|
Ambiguous
|
|
All of the above
|
Detailed explanation-1: -A grammar for which there are two different parse trees for the same terminal string is said to be ambiguous. We can prove this grammar is ambiguous by demonstrating two parse trees for the same terminal string.
Detailed explanation-2: -Explanation: ambiguous grammar has more than one parse tree.
Detailed explanation-3: -LR parser can be used to parse ambiguous grammars. LR parser resolves the conflicts (shift/reduce or reduce/reduce) in parsing table of ambiguous grammars based on certain rules (precedence and/or associativity of operators) of the grammar.
Detailed explanation-4: -Definition: A grammar is called ambiguous if there is a string for which there is more than one parse tree in the grammar.
Detailed explanation-5: -A grammar is said to be ambiguous if there exists more than one left most derivation or more than one right most derivation or more than one parse tree for a given input string. If the grammar is not ambiguous then we call unambiguous grammar.