Abstract
dc:description.abstractMany programming languages, such as Haskell and Python, use layout as part of their syntax. We can expect future programming languages to also be layoutsensitive. Therefore, the toolchains for implementing programming languages must support layout-sensitive languages. This thesis presents a declarative approach to describing layout-sensitive languages and parsing programs written in them. We reserve the terminals newline, indent, and dedent for describing layout syntax in BNF grammar and provide an algorithm for representing the layout of a program with these terminals, before parsing it. By verbalising layout syntax this way, mainstream parser generators, and their parsing algorithms, can be used. This approach is successfully implemented in BNF Converter (BNFC), a tool that generates a compiler front-end from a context-free grammar in Labelled BNF (LBNF) form. With a special kind of LBNF rule, called pragma, it is possible to declare global layout syntax rules, such as the offside rule, which affects the insertion of layout terminals by the aforementioned algorithm. The reserved terminals and the pragmas can together describe popular layout syntax. Furthermore, both purely layout-sensitive languages and those mixing layoutsensitive and insensitive syntax are describable in LBNF.
Degree
thesis:*- Level thesis:degree_level
- H
- Department dc:contributor.department
- Chalmers tekniska högskola / Institutionen för data och informationsteknik
- Year dc:date.issued
- 2023
Author and committee
dc:creator, dc:contributor.*- Author dc:creator
-
- Burreau, Beata
- Advisor dc:contributor.supervisor
-
- Abel, Andreas
- Committee member dc:contributor.committeemember
-
- Ranta, Aarne
Subjects
dc:subject × 7Identifiers
dc:identifier.*- Handle dc:identifier.uri
- https://hdl.handle.net/20.500.12380/307579