COMPOSABLE COMPILERS: EVOLUTION TOWARD A PRACTICAL REALITY A Dissertation Presented to the Faculty of the Graduate School of Cornell University in Partial Fulfillment of the Requirements for the Degree of Doctor of Philosophy by Chinawat Isradisaikul August 2017 c 2017 Chinawat Isradisaikul COMPOSABLE COMPILERS: EVOLUTION TOWARD A PRACTICAL REALITY Chinawat Isradisaikul, Ph.D. Cornell University 2017 The ability to add new features to programming languages is essential for language design experimentation and domain-specific developments, but implementing and maintaining small language extensions in traditional compilers remain a challenge. General-purpose programming languages do not have desired mechanisms to integrate small, indepen- dently developed extensions into a working programming language. At the same time, domain-specific languages that support such integration struggle to gain popularity in the programming language community. More language mechanisms and tools are needed as a middle ground so that a broader range of programmers can implement, maintain, and combine compilers for individual language features more easily. At the heart of compiler construction, new design patterns are proposed to allow compilers to be extended in a modular way and to be merged with little effort. These design patterns, implementable in a mainstream programming language, encode dynamic relationships between node types in abstract syntax trees (ASTs) so that inheritance in object-oriented programming still works over the course of language evolution. A new AST representation lets a single AST be viewed as different programs for different languages. Compiler passes are language-neutral, making translations reusable and composable. At the front end, engineering language syntax can be a painstaking process, espe- cially when individual language syntaxes start to interact. Automatic parser generators, albeit a powerful tool to parse complex grammars, are unhelpful when grammars are faulty, as reports of parsing conflicts do not explain these faults. To improve debugging experience, a semi-decision procedure is added to an LALR parser generator to give compact counterexamples illustrating why the grammar in question is ambiguous. For unambiguous grammars that cause parsing conflicts, a different kind of counterexample is constructed to aid removal of conflicts. At the back end, translation passes in compilers require extracting components of AST nodes. Pattern matching, an important feature in functional languages, is a prime candidate for this task. However, data abstraction and extensibility, two concepts central to object-oriented languages, are in conflict with pattern matching. A new language design based on modal abstraction reconciles static, modular reasoning about exhaustiveness in pattern matching with data abstraction. BIOGRAPHICAL SKETCH Chinawat (Chin) Isradisaikul [tCh¯in.n¯a.w´at `it.s¯a.r¯a:.d`i.sˇaj.k¯un] was born on the Day of Vesak 1985 (Visakha Bucha) in Phitsanulok [ph´it.s¯a.n´u.lˆo:k], Thailand. His first encounter with a computer was in the fifth grade, when he learned CU Writer, a Thai document processing program on DOS, in his lower school’s new computer lab. Although Chin did not own a computer until the tenth grade, his interactions with computers were continuous, thanks to opportunities in his middle school. Installing Windows 95 on dozens of desktop, connecting them to LAN, breaking a few of them, and developing the school’s website were part of his ninth-grade routine. BASIC was Chin’s first programming language which he learned upon graduat- ing from middle school and moving to Bangkok to attend Triam Udom Suksa School [tr¯ia:m.`u.d¯om.s`Wk.sˇa:]. During his first semester break, he attended a programming camp to learn C, which became his primary programming language throughout high school. Chin wrote an ASCII variant of Who Wants to Be a Millionaire? as his first C application for his friends and family to enjoy. The programming camp would be first of several camps that prepared Chin for representing Thailand in the International Olympiad in Informatics. Even if he missed the cut in the end, that was enough to qualify him for a Royal Thai Government scholarship to study abroad. He attended Westtown School in West Chester, Pennsylvania in 2004 as part of the college preparation program. There, he learned Java in his AP Computer Science class. Upon graduating from Westtown, Chin attended the University of Pennsylvania in Philadelphia, double majoring in computer science and mathematics. At Penn, his first CS course in discrete math introduced him to inference rules, which sparked his interest in logic and formal proofs. Chin’s interests in compilers grew out of the Introduction to Compilers course he took in his senior year, in which he learned his first functional programming language, OCaml, and implemented his first compiler without getting iii register allocation to work. He then moved to Ithaca, New York, to pursue a Ph.D. in computer science at Cornell University. Apart from research, Chin appreciates teaching and interacting with students, which in turn helped him become a better researcher. His dedication in teaching earned him the Yahoo! Outstanding Graduate Teaching Award in 2010. For most of his time in the United States, Chin has contributed academically to the Thai Scholar Program from helping new students adjust to American culture in the summer to proofreading their college applications every Christmas. In 2009, he implemented the Thai Scholar College Information System to streamline the college application process for Thai Scholars. The system has been in use since then, minimizing mundane tasks for both students and program staff. Outside academics, Chin loves nature, enjoys traveling, and practices photography. In 2012, he received training from the National Weather Service in Binghamton to become a SKYWARN spotter volunteer for Tompkins County. He served as the Cornell CS Photo Czar from 2013 to 2017, taking photos of incoming Ph.D. students. Chin is an avid skier, despite getting started after his A exam at Cornell. iv To my family, near and far. ACKNOWLEDGMENTS This dissertation would not be possible without help and advice from Andrew Myers, my advisor, who knows when to pull me ahead and when to push me from behind. Andrew, you showed me there is always a research problem to solve, whether easy or hard, whether decidable or undecidable. Whenever I seemed to run out of ideas, your suggestions usually gave me a way forward. You taught me how to give a good conference talk, restored my faith that constructive criticisms do exist, and warned me that it is possible to spend countless hours hacking TEX. For that, I am grateful. My Ph.D. career at Cornell would be less enjoyable without insightful and fun gradu- ate courses taught by Dexter Kozen and Bob Constable, my special committee members. Your courses kept my thoughts organized, kept my reasoning sound, and instilled in me the value of teaching and its connections with research. Your encouragements in our conversations propelled me through the finish line. For that, I am grateful. Past and present members of the Applied Programming Languages group—Steve Zdancewic, Nate Nystrom, Steve Chong, Jed Liu, Mike George, Krishnaprasad Vikram, Danfeng Zhang, Owen Arden, Tom Magrino, Yizhou Zhang, Isaac Sheff, Matthew Milano, and Ethan Cecchetti—contributed to my success as an undergraduate (Steve in this case) and a graduate student, whether academically, mentally, or morally. Countless interactions, countless hours, and countless comments you gave me made my scattered research ideas solid, made my convoluted paper drafts distinguished, and made my overambitious practice talks appreciated. For that, I am grateful. Ross Tate, Adrian Sampson, Aslan Askarov, Robert Soule,´ Abhishek Anand, Mark Reitblatt, Andrew Hirsch, Fabian Muehlboeck, and Harry Terkelsen are among other members of the programming languages field at Cornell CS who gave me invaluable suggestions and comments on my research papers. For that, I am thankful. vi Conveying research ideas would be less effective if communication skills were not kept practiced. I appreciate the opportunities in teaching from the Department of Computer Science, both at the University of Pennsylvania and at Cornell University, that allowed me to reinforce these skills. Val Tannen, Sampath Kannan, Daisy Fan, Andrew Myers, and Adrian Sampson were my role models who set a high expectation in structuring, managing, and running CS courses, small or large, undergrad or grad. They are excellent instructors who bring high-quality students to their courses for which I was on staff. In turn, these students propelled me to maintain a high standard as a teaching assistant. For that, I am thankful. Becky Stewart, Assistant Director of the Ph.D. Program, deals with everything from processing forms to answering hundreds of questions I had about keeping the department running and keeping my Ph.D. career going, or simply by being there just to chat. Becky, you helped me with bureaucrazy from the beginning to the end. For that, I am thankful. The Thai students and staff at Cornell not only form a tight-knit community that lets me wind down outside my research time, but also give me support when I need the most. Special thanks go to Apikanya (M) McCarty, Pakawat (Kun) Phalitnonkiat, Chayanee (Namtip) Chawanote, Raksit (A) Pattanapitoon, Kullachate (Oath) Muang- napoh, Tanapong (Nont) Jiarathanakul, Pimbucha (Pim) Rusmevichientong, Bunyarit (Pao) Meksiriporn, Sunsiree (Wahn) Kosindesha, Siraphat (Fay) Taesuwan, Chalermpat (Nong) Pariya-Ekkasut, Visarute (Earth) Pinrod, Ithipong (Billy) Assaranurak, Thapakorn (Hize) Jaroentomeechai, Kittkun (Ob) Songsomboon, Fikri (Fik) Pitsuwan, Pidchapon (Fai) Niruthisard, and Ravi (Note) Laohasurayodhin, who helped me with practice talks, tortured me with checkmate moves in the Settlers of Catan and Dominion, planned road trips, cooked good food, and went to snowy mountains with me. Guys, you kept me alive, kept me lively, and kept me in check during all these years. We are the force that will make Thailand an even better place.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages198 Page
-
File Size-