Write a Blog >>
Sun 22 - Fri 27 October 2017 Vancouver, Canada
Thu 26 Oct 2017 14:37 - 15:00 at Regency A - Mining Software Repositories and Parsing Chair(s): Wolfgang De Meuter

Precedence and associativity declarations in systems like yacc resolve ambiguities in context-free grammars (CFGs) by specifying restrictions on allowed parses. However, they are special purpose and do not handle many other grammatical restrictions that language designers need in order to resolve ambiguities like dangling else, the interactions between binary operators and functional if expressions in ML, and the interactions between object allocation and function calls in JavaScript. Often, language designers resort to restructuring their grammars in order to encode these restrictions, but this obfuscates the designer's intent and makes grammars difficult to read, write, and maintain.

In this paper, we show how tree automata can modularly and concisely encode such restrictions. We do this by reinterpreting CFGs as tree automata and intersecting them with tree automata encoding the desired restrictions. The results are then reinterpreted back into CFGs that encode the specified restrictions. This process can be used as a
preprocessing step before other CFG manipulations and is well behaved. It performs well in practice and never introduces ambiguities or LR($k$) conflicts.