COMPUTER SCIENCE AND ENGINEERING
COMPILER DESIGN
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Regular
|
|
Irregular
|
|
Ambiguous
|
|
Unambiguous
|
Detailed explanation-1: -A context-free grammar is called unambiguous grammar if there exists one and only one derivation tree or parse tree. Hence the correct answer is Ambiguous.
Detailed explanation-2: -A grammar can be unambiguous, if the grammar does not contain ambiguity. This means if it does not contain more than one left most derivation (LMD) or more than one right most derivation (RMD) or more than one parse tree for the given input string, it is an unambiguous grammar.
Detailed explanation-3: -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-4: -A grammar is said to be ambiguous if there exists more than one leftmost derivation or more than one rightmost derivation or more than one parse tree for the given input string. If the grammar is not ambiguous, then it is called unambiguous. If the grammar has ambiguity, then it is not good for compiler construction.
Detailed explanation-5: -We can prove this grammar is ambiguous by demonstrating two parse trees for the same terminal string. While in general it may be difficult to prove a grammar is ambiguous, the demonstration of two distinct parse trees for the same terminal string is sufficient proof that a grammar is ambiguous.