01whole.pdf (340.22 kB)
Attribute grammars: an executable specification for CSS layout
thesisposted on 2022-03-28, 15:23 authored by Scott Buckley
The World Wide Web is a technology used daily by billions of people internationally. The core technologies that make up the Web are specified by the World Wide Web Consortium, and implemented independently by various organisations in the form of web browsers, which are tools to retrieve and view HTML/CSS documents. The task of retrieving, parsing, and rendering an HTML document is very important and very complex. The specification that defines how an HTML page should be rendered (CSS) is more than 150,000 words long. It is well known that all web browsers render HTML differently in subtle ways, and we argue that the size and non-deterministic nature of the specification contributes to this problem. This project demonstrates a new method of a) describing the CSS specification, and b) implementing a CSS-compliant HTML renderer, that employs dynamic attribute grammars to achieve both tasks. Attribute grammars assist in specification by describing the relation-ship between the Document Object Model and its visual representation deterministically, and greatly reduce the gap between specification and implementation by writing the specification in an executable format. Furthermore, we show informally that this executable specification is human-readable, which we argue is because attribute grammars are the natural language to describe CSS.