Layout Syntax Support in the BNF Converter
dc.contributor.author | Burreau, Beata | |
dc.contributor.department | Chalmers tekniska högskola / Institutionen för data och informationsteknik | sv |
dc.contributor.department | Chalmers University of Technology / Department of Computer Science and Engineering | en |
dc.contributor.examiner | Ranta, Aarne | |
dc.contributor.supervisor | Abel, Andreas | |
dc.date.accessioned | 2024-02-16T10:54:41Z | |
dc.date.available | 2024-02-16T10:54:41Z | |
dc.date.issued | 2023 | |
dc.date.submitted | 2023 | |
dc.description.abstract | Many 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. | |
dc.identifier.uri | http://hdl.handle.net/20.500.12380/307579 | |
dc.setspec.uppsok | Technology | |
dc.subject | layout | |
dc.subject | syntax | |
dc.subject | indentation-sensitive language | |
dc.subject | context-free grammar | |
dc.subject | Labelled BNF (LBNF) | |
dc.subject | BNF Converter (BNFC) | |
dc.subject | Pfenning safety | |
dc.title | Layout Syntax Support in the BNF Converter | |
dc.type.degree | Examensarbete för masterexamen | sv |
dc.type.degree | Master's Thesis | en |
dc.type.uppsok | H | |
local.programme | Computer science – algorithms, languages and logic (MPALG), MSc |