Constructing parsers based on declarative specification of operator precedence is a very old research topic, and there are various existing approaches. However, these approaches are either tied to a particular parsing technique, or cannot deal with all corner cases found in programming languages. In this paper we present an implementation of declarative specification of operator precedence for general parsing that (1) is independent of the underlying parsing algorithm, (2) does not require any grammar transformation that increases the size of the grammar, (3) preserves the shape of parse trees of the original, natural grammar, and (4) can deal with intricate cases of operator precedence found in functional programming languages such as OCaml. Our new approach to operator precedence is formulated using data-dependent grammars, which extend context-free grammars with arbitrary computation, variable binding and constraints. We implemented our approach using Iguana, a data-dependent parsing framework, and evaluated it by parsing Java and OCaml source files. The results show that our approach is practical for parsing programming languages with complicated operator precedence rules.
Tue 19 JanDisplayed time zone: Guadalajara, Mexico City, Monterrey change
10:30 - 12:00 | Parsing & Domain-Specific Languages IPEPM at Room Harbor View Chair(s): Kenichi Asai Ochanomizu University | ||
10:30 30mTalk | Practical, General Parser Combinators PEPM Anastasia Izmaylova Centrum Wiskunde & Informatica, Ali Afroozeh Centrum Wiskunde & Informatica, Tijs van der Storm CWI DOI Pre-print | ||
11:00 30mTalk | Operator Precedence for Data-Dependent Grammars PEPM DOI Pre-print | ||
11:30 30mTalk | Everything Old Is New Again: Quoted Domain-Specific Languages PEPM Shayan Najd , Sam Lindley University of Edinburgh, Josef Svenningsson Chalmers University of Technology, Sweden, Philip Wadler University of Edinburgh DOI |