Abstract
Context-free grammars are suitable for formalizing the syntax of programming languages concisely and declaratively. Thus, such grammars are often found in reference manuals of programming languages, and used in language workbenches for language prototyping. However, the natural and concise way of writing a context-free grammar is often ambiguous.
Safe and complete declarative disambiguation of operator precedence and associativity conflicts guarantees that all ambiguities arising from combining the operators of the language are resolved. Ambiguities can occur due to shallow conflicts, which can be captured by one-level tree patterns, and deep conflicts, which require more elaborate techniques. Approaches to solve deep priority conflicts include grammar transformations, which may result in large unambiguous grammars, or may require adapted parser technologies to include data-dependency tracking at parse time.
In this paper we study deep priority conflicts "in the wild". We investigate the efficiency of grammar transformations to solve deep priority conflicts by using a lazy parse table generation technique. On top of lazily-generated parse tables, we define metrics, aiming to answer how often deep priority conflicts occur in real-world programs and to what extent programmers explicitly disambiguate programs themselves. By applying our metrics to a small corpus of popular open-source repositories we found that in OCaml, up to 17% of the source files contain deep priority conflicts.
Safe and complete declarative disambiguation of operator precedence and associativity conflicts guarantees that all ambiguities arising from combining the operators of the language are resolved. Ambiguities can occur due to shallow conflicts, which can be captured by one-level tree patterns, and deep conflicts, which require more elaborate techniques. Approaches to solve deep priority conflicts include grammar transformations, which may result in large unambiguous grammars, or may require adapted parser technologies to include data-dependency tracking at parse time.
In this paper we study deep priority conflicts "in the wild". We investigate the efficiency of grammar transformations to solve deep priority conflicts by using a lazy parse table generation technique. On top of lazily-generated parse tables, we define metrics, aiming to answer how often deep priority conflicts occur in real-world programs and to what extent programmers explicitly disambiguate programs themselves. By applying our metrics to a small corpus of popular open-source repositories we found that in OCaml, up to 17% of the source files contain deep priority conflicts.
Original language | English |
---|---|
Title of host publication | SLE 2017 Proceedings of the 10th ACM SIGPLAN International Conference on Software Language Engineering |
Editors | B. Combemale, M. Mernik, B. Rumpe |
Place of Publication | New York |
Publisher | Association for Computing Machinery (ACM) |
Pages | 55-66 |
Number of pages | 12 |
ISBN (Electronic) | 978-1-4503-5525-4 |
DOIs | |
Publication status | Published - 23 Oct 2017 |
Event | SLE 2017: The 10th ACM SIGPLAN International Conference on Software Language Engineering - Vancouver, Canada Duration: 23 Oct 2017 → 24 Oct 2017 |
Conference
Conference | SLE 2017 |
---|---|
Country/Territory | Canada |
City | Vancouver |
Period | 23/10/17 → 24/10/17 |
Keywords
- Disambiguation
- operator precedence
- declarative syntax definition
- grammars
- empirical study