Declarative specification of indentation rules: A tooling perspective on parsing and pretty-printing layout-sensitive languages

Research output: Chapter in Book/Conference proceedings/Edited volumeConference contributionScientificpeer-review

1 Citation (Scopus)
120 Downloads (Pure)


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.

Original languageEnglish
Title of host publicationSLE 2018 - Proceedings of the 11th ACM SIGPLAN International Conference on Soft ware Language Engineering
EditorsD. Pearce , S. Friedrich, T. Mayerhofer
Place of PublicationNew York, NY
PublisherAssociation for Computing Machinery (ACM)
Number of pages13
ISBN (Electronic)978-1-4503-6029-6
Publication statusPublished - 2018
EventSLE 2018: 11th ACM SIGPLAN International Conference on Software Language Engineering - Boston, United States
Duration: 5 Nov 20186 Nov 2018
Conference number: 11


ConferenceSLE 2018
CountryUnited States
OtherPart of SPLASH 2018

Fingerprint Dive into the research topics of 'Declarative specification of indentation rules: A tooling perspective on parsing and pretty-printing layout-sensitive languages'. Together they form a unique fingerprint.

Cite this