Declarative specification of indentation rules

A tooling perspective on parsing and pretty-printing layout-sensitive languages

Conference Paper (2018)
Author(s)

Luís Eduardo de Souza Amorim (TU Delft - Programming Languages)

Sebastian Erdweg (TU Delft - Programming Languages)

Michael J. Steindorfer (TU Delft - Programming Languages)

Eelco Visser (TU Delft - Programming Languages)

DOI related publication
https://doi.org/10.1145/3276604.3276607 Final published version
More Info
expand_more
Publication Year
2018
Language
English
Pages (from-to)
3-15
ISBN (electronic)
978-1-4503-6029-6
Event
Downloads counter
318
Collections
Institutional Repository
Reuse Rights

Other than for strictly personal use, it is not permitted to download, forward or distribute the text or part of it, without the consent of the author(s) and/or copyright holder(s), unless the work is under an open content license such as Creative Commons.

Abstract

In layout-sensitive languages, the indentation of an expression or statement can influence how a program is parsed. While some of these languages (e.g., Haskell and Python) have been widely adopted, there is little support for software language engineers in building tools for layout-sensitive languages. As a result, parsers, pretty-printers, program anal-yses, and refactoring tools often need to be handwritten, which decreases the maintainability and extensibility of these tools. Even state-of-the-art language workbenches have little support for layout-sensitive languages, restricting the development and prototyping of such languages. In this paper, we introduce a novel approach to declarative specification of layout-sensitive languages using layout declarations. Layout declarations are high-level specifications of indentation rules that abstract from low-level technicalities. We show how to derive an efficient layout-sensitive generalized parser and a corresponding pretty-printer automatically from a language specification with layout declarations. We validate our approach in a case-study using a syntax definition for the Haskell programming language, investigating the performance of the generated parser and the correctness of the generated pretty-printer against 22191 Haskell files.

Files