انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

Ambiguity

الكلية كلية العلوم للبنات     القسم قسم الحاسبات     المرحلة 2
أستاذ المادة زينب فلاح حسن الكيم       05/12/2015 18:09:34
A context-free grammar G is called ambiguous if some word has more than one leftmost derivation (equivalently: more than one derivation tree).
Grammar with strings that have two or more distinct parse trees, are called ambiguous. Assigning a parse tree to a given string in the language is called parsing the string, it is an important first step towards understanding the structure of the string. Ambiguous grammars are of no help in parsing, since they assign no unique parse tree to each string in the language.
In fact, there are context free languages with the property that all context free grammars that generate must be ambiguous. Such languages are called inherently ambiguous.
An ambiguous grammar has more than one leftmost derivation and more than one rightmost derivation for a single sentential form.
Example 1:
Consider the sential form E+E*E, it has two derivation from E:
1. E ?E+E ?E+E*E
2. E? E*E? E+E*E
Notice that in derivation (1), the second E is replaced by E*E, while in derivation (2), the first E is replaced by E+E. The figuare shows the two parse trees. In derivation(1), the second and third expressions are multiplied, and the result is added to the first expression, while derivation (2) adds the first two expressions and multiplies the result by the third. In more concrete terms, the first derivation suggests that 1+2*3 should be grouped 1+(2*3)=7, while the second derivation suggests the same expression should be grouped (1+2)*3=9.
Consider the sentence ID+ID×ID. This can be parsed in two different ways.



المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .