33 research outputs found

    Tracking Down the Origins of Ambiguity in Context-Free Grammars

    Get PDF
    Context-free grammars are widely used but still hindered by ambiguity. This stresses the need for detailed detection methods that point out the sources of ambiguity in a grammar. In this paper we show how the approximative Noncanonical Unambiguity Test by Schmitz can be extended to conservatively identify production rules that do not contribute to the ambiguity of a grammar. We prove the correctness of our approach and consider its practical applicability

    Tracking Down the Origins of Ambiguity in Context-Free Grammars

    Get PDF
    Context-free grammars are widely used but still hindered by ambiguity. This stresses the need for detailed detection methods that point out the sources of ambiguity in a grammar. In this paper we show how the approximative Noncanonical Unambiguity Test by Schmitz can be extended to conservatively identify production rules that do not contribute to the ambiguity of a grammar. Furthermore we can identify tree patterns that will never occur in derivations of ambiguous strings. We prove the correctness of our approach and consider its practical applicability

    Tracking Down the Origins of Ambiguity in Context-Free Grammars

    Get PDF
    Context-free grammars are widely used but still hindered by ambiguity. This stresses the need for detailed detection methods that point out the sources of ambiguity in a grammar. In this paper we show how the approximative Noncanonical Unambiguity Test by Schmitz can be extended to conservatively identify production rules that do not contribute to the ambiguity of a grammar. We prove the correctness of our approach and consider its practical applicability

    Alternative Method To Check Ambiguity In Context Free Grammars

    Get PDF
    Compilation of source code from different papers and books is a tedious and lengthy process. The result of the first phase of compilation, which is tokens, is given to the next phase called parsing which outputs a parse tree (also called syntax tree) to a grammar for a given input string. If there is more than one parse tree which are different with one another, then it calls the grammar as ambiguous grammar, or in short there exists an ambiguity in the grammar This paper tries to present an alternative method for checking the so called ambiguity problem in context free grammars by having an infix tree structure for a given input and comparing it with the corresponding parse trees and obtained from the given grammar in a top-down parsing approac

    Exploring the Problem of Ambiguity in Context-free Grammars

    Get PDF
    The general problem of ambiguity detection is unsolvable. Some context-free languages are inherently ambiguous. There is no algorithm that can detect the ambiguity of context-free grammars (CFG) in general since it is a provably unsolvable problem. The objective of this thesis is to study the notion of ambiguity in context-free grammars and grammars in general. The areas of this study include ambiguity in CFGs, ambiguity in other classes of grammars, and a number of algorithms for finding ambiguous strings and grammars. Also, an algorithm that finds ambiguous strings in a subset of context-free grammars is presented. This algorithm is based on the observation that ambiguity in strings cannot be induced by mere repetitions of applications of productions unless ambiguous strings can be generated without exhibiting the self-embedding property.Ambiguity in different classes of formal languages and in some programming languages was studied. The problem of ambiguity detection in context-free grammars was studied in depth. An algorithm was designed and implemented to detect ambiguous strings generated by a subset of context-free grammars. The algorithm works successfully for all grammars in the test suite of grammars which are known to be either ambiguous or unambiguous. It was observed that checking the sentential forms for ambiguity instead of checking only the sentences, and applying the productions of the proper grammar instead of the CNF grammar to derive the sentential forms are promising techniques to keep the execution time low. It was also observed that the time in which ambiguity was detected in the grammars in the test suite was largely independent of factors such as the productivity of a grammar (the number of strings that can be generated without exhibiting the self-embedding property), the degree of ambiguity of a string, and the lengths of strings generated.Computer Science Departmen

    Ambiguity of context-free languages as a function of the word length

    Get PDF
    Englische Fassung der Diplomarbeit "Grad der Mehrdeutigkeit kontextfreier Grammatiken und Sprachen". In dieser Arbeit definieren wir ein Maß für den Grad der Mehrdeutigkeit (degree of ambiguity da) kontextfreier Grammatiken und Sprachen als die Anzahl der Ableitungsbäume in Abhängigkeit von der Länge n eines Wortes. Wir zeigen, dass es weder Sprachen noch zyklenfreie Grammatiken gibt, deren Mehrdeutigkeitsgrad stärker als 2£(n) wächst (wie z B. £(nn)). Aus [10] ist es außerdem bekannt, dass es keine Grammatiken (und somit keine Sprachen) gibt, deren Mehrdeutigkeit stärker als polynomiell, aber schwächer als exponentiell wächst (wie z. B. £(2pn). Deshalb untersuchen wir in dieser Arbeit hauptsächlich konstant mehrdeutige, polynomiell mehrdeutige und exponentiell mehrdeutige Grammatiken und Sprachen. Für jede feste, ganze Zahl k 2 N hat Maurer [8] die Existenz einer k-deutigen kontextfreien Sprache nachgewiesen. Durch Verwendung einer einfacheren Sprache, nämlich der Sprache Lk := fambm1 1 bm2 2 : : : bmk k jm;m1;m2; : : : ;mk ¸ 1; 9 i mit m = mig, und mit Hilfe von Ogden's Lemma1 erhalten wir einen wesentlich kürzeren Beweis. Ferner zeigen wir die Existenz exponentiell mehrdeutiger Sprachen. Wir zeigen, dass die Sprache L¤ { wobei L = faibicj ji; j ¸ 1g [ faibjciji; j ¸ 1g-exponentiell mehrdeutig ist, indem wir beweisen, dass das Wort (ah+h!bh+h!ch+h!)k mindestens 2k Ableitungen in jeder Grammatik G für L¤ hat, wobei k aus N ist und h die Konstante aus Ogden's Lemma für G ist. Für beliebig kleines c aus R+ entwerfen wir eine Grammatik Gc für L¤, so dass daGc · 2cn gilt. Somit gilt, dass die Sprache L¤ zwar exponentiell mehrdeutig ist, aber es gibt kein festes c aus R+ , so dass L¤ 2cn-deutig ist. Wir geben polynomiell mehrdeutige Grammatiken an und zeigen die Existenz von polynomiell mehrdeutigen Sprachen, indem wir mit Hilfe von Ogden's Lemma beweisen, dass die Anzahl der Ableitungsbäume eines Wortes der Länge n in jeder Grammatik für die Sprache Lk in der Größenordnung von ­(nk) liegt, wobei k eine Konstante aus N ist, und L := fambm1cbm2c : : : bmpcjp 2 N; m;m1;m2; : : : ;mp 2 N; 9i 2 f1; 2; : : : ; pg mit m = mig gilt. Durch Angabe einer O(nk){deutigen Grammatik zeigen wir schließlich, dass Lk polynomiell vom Grad k mehrdeutig ist. Außerdem entwerfen wir für jedes feste d aus R+ eine Grammatik Gd für L, so dass daGd · dn dn für genügend großes n ist.In this paper we discus the concept of ambiguity of context{free languages and grammars. We prove the existence of constant ambigu- ous, exponential ambiguous and polynomial ambiguous languages and we give examples for these classes of ambiguity

    Parse Forest Diagnostics with Dr. Ambiguity

    Get PDF
    In this paper we propose and evaluate a method for locating causes of ambiguity in context-free grammars by automatic analysis of parse forests. A parse forest is the set of parse trees of an ambiguous sentence. % an output of a static ambiguity detection tool that has detected ambiguity in a context-free grammar or of a general parser that has accidentally parsed an ambiguous sentence. Deducing causes of ambiguity from observing parse forests is hard for grammar engineers because of (a) the size of the parse forests, (b) the complex shape of parse forests, and (c) the diversity of causes of ambiguity. We first analyze the diversity of ambiguities in grammars for programming languages and the diversity of solutions to these ambiguities. Then we introduce \drambiguity: a parse forest diagnostics tools that explains the causes of ambiguity by analyzing differences between parse trees and proposes solutions. We demonstrate its effectiveness using a small experiment with a grammar for Java 5

    Practical Ambiguity Detection for Context-Free Grammars

    Get PDF
    The use of unconstrained context-free grammars for generalized parsing techniques has several advantages over traditional grammar classes, but comes with the danger of undiscovered ambiguities. The ambiguity problem for these grammars is undecidable in the general case, but this does not have to be a problem in practice. Our goal is to find ambiguity detection techniques that have sufficient precision and performance to make them suitable for practical use on realistic grammars. We give a short overview of related work, and propose new directions for improvement

    Faster ambiguity detection by grammar filtering

    Get PDF
    Real programming languages are often defined using ambiguous context-free grammars. Some ambiguity is intentional while other ambiguity is accidental. A good grammar development environment should therefore contain a static ambiguity checker to help the grammar engineer. Ambiguity of context-free grammars is an undecidable property. Nevertheless, various imperfect ambiguity checkers exist. Exhaustive methods are accurate, but suffer from non-termination. Termination is guaranteed by approximative methods, at the expense of accuracy. In this paper we combine an approximative method with an exhaustive method. We present an extension to the Noncanonical Unambiguity Test that identifies production rules that do not contribute to the ambiguity of a grammar and show how this information can be used to significantly reduce the search space of exhaustive methods. Our experimental evaluation on a number of real world grammars shows orders of magnitude gains in efficiency in some cases and negligible losses of efficiency in others
    corecore