MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

COMPILER DESIGN

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
A grammar that produces more than one parse tree for some sentence is called as
A
CFG
B
Ambiguous
C
Non Ambiguous
D
Left Recursive
Explanation: 

Detailed explanation-1: -The correct answer is option 2. Concept: A grammar that produces more than one parse tree for some sentence is said to be ambiguous.

Detailed explanation-2: -A Grammar that makes more than one Leftmost Derivation (or Rightmost Derivation) for the similar sentence is called Ambiguous Grammar.

Detailed explanation-3: -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.

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: -A grammar is ambiguous if it has more than one leftmost derivations for a sentence. That’s equivalent to saying that it had more than one rightmost derivation for the same sentence because the is a one-to-one correspondence between leftmost and rightmost derivations.

There is 1 question to complete.