Layout Syntax Support in the BNF Converter

dc.contributor.authorBurreau, Beata
dc.contributor.departmentChalmers tekniska högskola / Institutionen för data och informationstekniksv
dc.contributor.departmentChalmers University of Technology / Department of Computer Science and Engineeringen
dc.contributor.examinerRanta, Aarne
dc.contributor.supervisorAbel, Andreas
dc.date.accessioned2024-02-16T10:54:41Z
dc.date.available2024-02-16T10:54:41Z
dc.date.issued2023
dc.date.submitted2023
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.
dc.identifier.urihttp://hdl.handle.net/20.500.12380/307579
dc.setspec.uppsokTechnology
dc.subjectlayout
dc.subjectsyntax
dc.subjectindentation-sensitive language
dc.subjectcontext-free grammar
dc.subjectLabelled BNF (LBNF)
dc.subjectBNF Converter (BNFC)
dc.subjectPfenning safety
dc.titleLayout Syntax Support in the BNF Converter
dc.type.degreeExamensarbete för masterexamensv
dc.type.degreeMaster's Thesisen
dc.type.uppsokH
local.programmeComputer science – algorithms, languages and logic (MPALG), MSc
Ladda ner
Original bundle
Visar 1 - 1 av 1
Hämtar...
Bild (thumbnail)
Namn:
CSE 23-165 BB.pdf
Storlek:
373.18 KB
Format:
Adobe Portable Document Format
Beskrivning:
License bundle
Visar 1 - 1 av 1
Hämtar...
Bild (thumbnail)
Namn:
license.txt
Storlek:
2.35 KB
Format:
Item-specific license agreed upon to submission
Beskrivning: