
First Class Syntax, Semantics, and Their Composition Marcos Viera Author: Marcos Viera, 2012 Printed by: W¨ohrmannPrint Service Cover: El Carafon de primera by Alessandro Spinuso, 2012 First Class Syntax, Semantics, and Their Composition Eerste klas syntax, semantiek en hun samenstelling (met een samenvatting in het Nederlands) Proefschrift ter verkrijging van de graad van doctor aan de Universiteit Utrecht op gezag van de rector magnificus, prof.dr. G.J. van der Zwaan, ingevolge het besluit van het college voor promoties in het openbaar te verdedigen op vrijdag 8 maart 2013 des middags te 4.15 uur door Marcos Viera geboren op 9 september 1979 te San Jos´e,Uruguay Promotoren: Prof.dr. S. D. Swierstra Prof.dr. A. Pardo Preface Ideally complexity is managed by composing a system out of quite a few, more or less independent, and much smaller descriptions of various aspects of the overall artifact. When describing (extensible) programming languages, attribute grammars have turned out to be an excellent tool for modular definition and integration of their different aspects. In this thesis we show how to construct a programming language implementation by composing a collection of attribute grammar fragments describing separate aspects of the language. More specifically we describe a coherent set of libraries and tools which together make this possible in Haskell, where the correctness of the composition is enforced through the Haskell type system's ability to represent attribute grammars as plain Haskell values and their interfaces as Haskell types. Semantic objects thus constructed can be combined with parsers which are con- structed on the fly out of parser fragments and are also represented as typed Haskell values. Again the type checker prevents insane compositions. As a small case study of the techniques proposed in this thesis, we implemented a compiler for the (Pascal-like) imperative language Oberon0. Through an incremental design, we show the modularity capacities of our techniques. Acknowledgements. As this story has been written on two sides of the Atlantic, I feel obliged to thank in two languages. Since ik spreek geen Nederlands, the people I met at the eastern side of the Atlantic will be acknowledged in English. I am very grateful to my promotor Doaitse Swierstra, who introduced me to the Haskell type-level puzzling world. It is impossible not to get contagious with his passion for our research area. He is a never ending source of ideas, which he has no problems on sharing, always starting with the sentence: \I have been thinking while biking home...". Doaitse is not only an excellent scientist. I discovered, while working with him, that he is also a very good person. Gracias, se~norde Holanda! I want to thank Wilke and Tineke Schram, who hosted me at their home during my first month in Utrecht, helping me a lot while I was taking my first baby steps into the dutch society. The Software Technology group is a very good place where to work, its members are very talented researchers and also very kind people. Although I was there for a relatively short time, they treated my as if I was a member of the group. I thank Jurriaan for his continuous visits to my office, trying to convince me that drops was something that deserved to be tasted. The foosball sessions deserve a separate chapter. We had a lot of fun producing all those weird vocalism, as a result of the excitement for this \sport". Thanks to 1 Preface Am´erico,Arthur, Jos´ePedro, Juan Francisco, Martijn, Reinier, Rodrigo and Sean for such a great time. I took a couple of master courses in Utrecht to catch up with the research area I had to work on. Both courses were very helpful and inspiring. So I am very grateful to the great lecturers, Andres L¨ohand Jeroen Fokker. I also want to thank my co-authors Arthur, Doaitse, Wouter, Arie and Atze, it was a pleasure and a honour to work with you and learn from you. I am thankful to the members of the reading committee, Roland Backhouse, Koen Claessen, Johan Jeuring, Rinus Plasmeijer and Joao Saraiva, who kindly accepted to read my thesis. Alessandro did a great work designing the cover of my thesis. He even took the risk of getting a fee on a Belgian train, for sitting in first class with a second class ticket, in order to set up what was needed to take the picture. I do not know if the material inside the thesis is that good, but I am sure its cover is a piece of art. Finally, I want to spend some words on the group of friends who made me feel like home while I was there. Until I met them I did not know that someone can construct a friendship in such a short time. I have plenty of moments stored in my hearth, from quiet nice conversations to endless nights trying to convince me not to finish at Carafon. Alessandro, Am´erico,Alexey, David, Despoina, Juan Francisco, Luca, Martijn and Tizy, thanks to you, when I think about my days in Utrecht I have this feeling that the Brazilians call saudade. Como esta fue una historia escrita en dos m´argenesdel Atl´antico, me vi obligado a agradecer en dos idiomas. Luego de haber agradecido en ingl´esa aquellos que conoc´ı en mi aventura europea, me toca agradecer en mi lengua a aquellos que en nuestro paisito me han acompa~nadoen esta etapa tan importante de mi vida. Repasando la secci´onde agradecimientos de mi tesis de maestr´ıa,con la desesperada intenci´onde autoplagiarme un poco, tuve la grata confirmaci´onde que a pesar de que el tiempo ha pasado, y varios pelos se han ido fugando, los afectos siguen intactos. De verdad que casi que podr´ıacopiar y pegar aqu´ıaquellas palabras que escrib´ıhace ya m´asde cinco a~nosy, agregando algunos nuevos nombres, tendr´ıanla misma validez. Pero no voy a ser tan mezquino, la gratitud merece ser renovada con palabras nuevas, y aqu´ıvan... El Instituto de Computaci´ones un lugar en el que me gusta mucho trabajar, a pesar de los 90 kil´ometros que tengo que hacer para llegar hasta ah´ı,y eso se debe b´asicamente a la gente que se encuentra dispersa a lo largo de ese interminable pasillo del quinto piso y en los kibutz del cuerpo norte. Desde la visita por secretar´ıapara recibir alg´uncomentario ´acidode Lucyla o Daniela, hasta las charlas de oficina, mate mediante, con Andrea, Daniel o M´onica,hacen del trabajo diario algo muy disfrutable y eso lo tengo que agradecer. Quiero agradecer a mi supervisor, Alberto Pardo, quien me ha guiado paso a paso en este proceso de iniciaci´ona la vida acad´emica,estando siempre disponible para resolver cualquier cosa que le haya ido a plantear. Por suerte todav´ıame queda mucho por aprender de Alberto. 2 Preface Tambi´enquiero agradecer a aquellos con los que he compartido la escritura de (proyectos de) papers en esta ´ultimaetapa. Gracias a Alberto, Bruno, Mart´ın,Mauro, Pablo y Pablo (E), por considerar al menos por un rato que lo que hacemos pueda llegar a ser interesante. En todas las instancias del curso de Programaci´on2 en las que he trabajado siempre me han tocado buenos grupos de compa~neros.A trav´esde sus co-responsables, Carlos y Lorena, les agradezco a todos ellos, por el buen trabajo y por la flexibilidad que siempre han mostrado cuando esta tesis le quit´oalg´untiempo al curso. Quiero agradecer a todos los miembros del PEDECIBA Inform´aticay a su secretaria Mar´ıaIn´es.En especial quiero agradecer a los integrantes del Consejo Cient´ıficoque junto con Daniel tuvimos la suerte de integrar como delegados estudiantiles. Agradezco profundamente a todos mis amigos, los de siempre. Los que parece que nada tienen que ver con todo esto pero que en realidad son grandes culpables de lo que soy. A mis padres, a quienes no me cansar´ede decirles que me enorgullece ser su hijo, y que no me alcanzar´ala vida para agradecer lo que han hecho por mi. A Carolina. Recuerdo que hace ya varios a~noste di aquella tarjeta que dec´ıaque \no hay nada m´ashermoso que el amor que ha sobrellevado las tormentas de la vida", y la profec´ıase va cumpliendo, porque nuestro amor es hermoso. Primero en Montevideo, luego sobrevivir a la distancia y ahora en San Jos´e,viviendo el sue~no, con el peque~noDante, el mejor regalo que nos pudo haber dado la vida. Como se que no lo voy a poder describir mejor, le robo estas palabras a Drexler para decirte \que el coraz´onno miente, que afortunadamente, me haces bien, me haces bien, me haces bien". Sponsors. I am grateful to the European project LerNet and PEDECIBA Inform´atica, who respectively funded the 75% and 25% of my eighteen months stay in the Nether- lands. ANII financed another one month internship at the Utrecht University to be able to meet my supervisor and advance in my thesis. From 2009 to 2011, I received a grant for my PhD studies from the Engineering School of Universidad de la Rep´ublica. 3 Contents Preface 1 1 Introduction 7 1.1 Extensible Languages . .8 1.1.1 Language Extension . 11 1.2 First-Class Syntax . 13 1.2.1 Grammar Representation . 13 1.2.2 Grammar Extensions . 13 1.2.3 Closed Grammars . 14 1.3 First-Class Semantics . 15 1.3.1 Definition of the Language Semantics . 15 1.3.2 Extending the Semantics .
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages180 Page
-
File Size-