Final Report

Total Page:16

File Type:pdf, Size:1020Kb

Final Report PLT Fall 2018 Shoo The Final Report Claire Adams (cba2126) Samurdha Jayasinghe (sj2564) Cindy Le (xl2738) Crystal Ren (cr2833) December 18, 2018 Contents 1 Introduction 9 1.1 White Paper . .9 1.1.1 Powerful . .9 1.1.2 Convenient . .9 1.1.3 Portable . .9 2 Tutorial 9 2.1 Environment Setup . .9 2.2 Compilation Guide . 10 2.3 Language Tutorial . 11 3 Language Manual 11 3.1 Comments and Whitespace . 11 3.1.1 Single-line Comments . 11 3.1.2 Multi-line Comments . 11 3.1.3 Whitespace . 12 3.2 Data Types . 12 3.2.1 Primitive Data Types . 12 3.2.2 The Void Keyword . 12 3.3 Variables . 13 3.3.1 Variable Naming . 13 3.3.2 Scope of Variables . 13 3.3.3 Variable Declarations . 13 3.3.4 Variable Assignment . 13 3.4 Arrays . 14 3.4.1 Declaring Arrays . 14 3.4.2 Defining Arrays . 14 3.4.3 Arrays in Arrays . 15 3.4.4 Accessing Array Elements . 16 3.5 Structs . 16 3.5.1 Declaring Structs . 16 3.5.2 Variables of Type Struct . 17 3.5.3 Defining Variables of Type Struct . 18 3.5.4 Dot Operator . 18 3.5.5 Destructuring Assignment of Structs . 18 3.6 Operators . 19 3.6.1 Precedence and Associativity . 19 3.6.2 Assignment Operator . 20 3.6.3 Arithmetic Operators . 20 3.6.4 Logical Operators . 21 3.6.5 Increment and Decrement Operators . 21 3.7 Statements . 21 3.7.1 Simple Statements . 21 3.7.2 The For Loops . 21 1 3.7.3 The While Loops . 22 3.7.4 The If Statements . 23 3.8 Functions . 23 3.8.1 Function Declarations . 23 3.8.2 Function Definitions . 24 3.8.3 Calling Functions . 26 3.9 Built-in Functions . 26 3.9.1 print . 26 3.9.2 println . 26 3.9.3 str of bool................................. 26 3.9.4 str of float . 26 3.9.5 str of int.................................. 27 3.9.6 string concat . 27 3.9.7 string equals . 27 3.9.8 int of float . 27 3.9.9 int of str ................................. 27 3.9.10 float of int................................. 27 3.9.11 scan line . 27 3.9.12 scan char.................................. 28 3.9.13 die . 28 3.9.14 exit success . 28 3.9.15 rand autoseed . 28 3.9.16 rand afterseed . 28 4 Project Plan 28 4.1 Planning, Specification, Development, and Testing . 28 4.2 Style Guide . 29 4.3 Project Timeline . 30 4.3.1 Planned Timeline . 30 4.3.2 Actual Project Timeline . 31 4.4 Team Roles and Responsibilities . 31 4.5 Software Development Environment . 32 4.6 Project Log . 32 5 Language Evolution 32 5.1 Original Thoughts . 33 5.2 Narrowing Down the Scope . 33 5.3 Design Choices for Syntax . 33 5.4 Design Choices for Functionality . 34 5.5 Design Summary . 34 6 Translator Architecture 35 6.1 Lexer . 35 6.2 Parser . 35 6.3 Semantic Checking . 35 6.4 First Class Function Lifter . 36 2 6.5 Code Generation . 36 6.6 C Libraries . 37 7 Test Plan 37 7.1 Unit Testing . 37 7.2 Integration Tests . 38 7.2.1 Test Automation and Scripts . 38 7.3 Example Test Programs . 39 7.4 Division of Labor for Testing . 61 8 Conclusions and Lessons Learned 61 8.1 Claire . 61 8.2 Cindy . 61 8.3 Sam . 61 8.4 Crystal . 62 9 Acknowledgements 62 10 Appendix 62 10.1 Project Log . 62 10.2 shoo.ml . 127 10.3 scanner.mll . 128 10.4 ast.ml . 129 10.5 parser.mly . 134 10.6 sast.ml . 139 10.7 semant.ml . 143 10.8 lift.ml . 154 10.9 codegen.ml . 160 10.10 builtins.c . 172 10.11 Makefile . 175 10.12 testall.sh . ..
Recommended publications
  • CRN What It Was Doing and Why It Was Cognitive Systems Vision Doing It, and to Recover from Mental Continued on Page 8 Expanding the Pipeline
    COMPUTING RESEARCH NEWS Computing Research Association, Celebrating 30 Years of Service to the Computing Research Community November 2002 Vol. 14/No. 5 DARPA’s New Cognitive Systems Vision By Ron Brachman and IPTO’s goal is to create a new to cope with systems both keep Zachary Lemnios generation of cognitive systems. growing. In order to make our systems more reliable, more secure, The impact of the Defense Mired in Moore’s Law? and more understandable, and to Advanced Research Projects Agency One benefit of such cognitive continue making substantial contri- (DARPA) on computing over the systems would be their help in butions to society, we need to do past 40 years has been profound. Led extracting us from a corner into something dramatically different. by the visionary J.C.R. Licklider and which our success seems to have his innovative successors in the painted us. The research that has The Promise of Cognitive Information Processing Techniques helped the industry follow Moore’s Systems Office (IPTO), DARPA initiated “Law” has created processors that are IPTO is attacking this problem by work that ultimately put personal remarkably fast and small, and data driving a fundamental change in computers on millions of desktops storage capabilities that are vast and computing systems. By giving systems Ron Brachman and made the global Internet a cheap. Unfortunately, these incred- more cognitive capabilities, we reality. In fact, the original IPTO, ible developments have cut two ways. believe we can make them more which lasted from 1962 to 1985, was While today’s computers are more responsible for their own behavior in large part responsible for estab- powerful than ever, we have been and maintenance.
    [Show full text]
  • The AWK Programming Language
    The Programming ~" ·. Language PolyAWK- The Toolbox Language· Auru:o V. AHo BRIAN W.I<ERNIGHAN PETER J. WEINBERGER TheAWK4 Programming~ Language TheAWI(. Programming~ Language ALFRED V. AHo BRIAN w. KERNIGHAN PETER J. WEINBERGER AT& T Bell Laboratories Murray Hill, New Jersey A ADDISON-WESLEY•• PUBLISHING COMPANY Reading, Massachusetts • Menlo Park, California • New York Don Mills, Ontario • Wokingham, England • Amsterdam • Bonn Sydney • Singapore • Tokyo • Madrid • Bogota Santiago • San Juan This book is in the Addison-Wesley Series in Computer Science Michael A. Harrison Consulting Editor Library of Congress Cataloging-in-Publication Data Aho, Alfred V. The AWK programming language. Includes index. I. AWK (Computer program language) I. Kernighan, Brian W. II. Weinberger, Peter J. III. Title. QA76.73.A95A35 1988 005.13'3 87-17566 ISBN 0-201-07981-X This book was typeset in Times Roman and Courier by the authors, using an Autologic APS-5 phototypesetter and a DEC VAX 8550 running the 9th Edition of the UNIX~ operating system. -~- ATs.T Copyright c 1988 by Bell Telephone Laboratories, Incorporated. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopy­ ing, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America. Published simultaneously in Canada. UNIX is a registered trademark of AT&T. DEFGHIJ-AL-898 PREFACE Computer users spend a lot of time doing simple, mechanical data manipula­ tion - changing the format of data, checking its validity, finding items with some property, adding up numbers, printing reports, and the like.
    [Show full text]
  • Sensory Information Processing (1 January 1976
    Im plem enting Functional Program s Using M utable Abstract Data Types Ganesh C. Gopalakrishnan, Department of Computer Science, Univ. of Utah, Salt Lake City, Utah 84112 and Mandayam K. Srivas, Department of Computer Science, SUNY, Stony Brook, N Y 11794 W e study the following problem in this paper. Suppose we have a purely functional program that uses a set of abstract data types by invoking their operations. Is there an order of evaluation of the operations in the program that preserves the applicative order of evaluation semantics of the program even when the abstract data types behave as mutable modules. An abstract data type is mutable if one of its operations destructively updates the object rather than returning a new object as a result. This problem is important for several reasons. It can help eliminate unnecessary copying of data structure states. It supports a methodology in which one can program in a purely functional notation for purposes of verification and clarity, and then automatically transform the program into one in an object oriented, imperative language, such as CLU, A D A , Smalltalk, etc., that supports abstract data types. It allows accruing both the benefits of using abstract data types in programming, and allows modularity and verifiability. Keywords: Functional Program Implementation, Mutable Modules, Abstract Data Types, Syntactic Conditions. C o n t e n t s 1 Introduction 1 1.1 Related W o r k ........................................................................................................................... 2 1.2 Terminology, Assumptions, and Problem Statement............................................... 2 2 Syntactic Characterization of In Situ Evaluability 3 2.1 Syntactic Conditions for Straight-line Expressions..................................................
    [Show full text]
  • Understanding Programming Languages
    Understanding Programming Languages M. Ben-Ari Weizmann Institute of Science Originally published by John Wiley & Sons, Chichester, 1996. Copyright °c 2006 by M. Ben-Ari. You may download, display and print one copy for your personal use in non-commercial academic research and teaching. Instructors in non-commerical academic institutions may make one copy for each student in his/her class. All other rights reserved. In particular, posting this document on web sites is prohibited without the express permission of the author. Contents Preface xi I Introduction to Programming Languages 1 1 What Are Programming Languages? 2 1.1 The wrong question . 2 1.2 Imperative languages . 4 1.3 Data-oriented languages . 7 1.4 Object-oriented languages . 11 1.5 Non-imperative languages . 12 1.6 Standardization . 13 1.7 Computer architecture . 13 1.8 * Computability . 16 1.9 Exercises . 17 2 Elements of Programming Languages 18 2.1 Syntax . 18 2.2 * Semantics . 20 2.3 Data . 21 2.4 The assignment statement . 22 2.5 Type checking . 23 2.6 Control statements . 24 2.7 Subprograms . 24 2.8 Modules . 25 2.9 Exercises . 26 v Contents vi 3 Programming Environments 27 3.1 Editor . 28 3.2 Compiler . 28 3.3 Librarian . 30 3.4 Linker . 31 3.5 Loader . 32 3.6 Debugger . 32 3.7 Profiler . 33 3.8 Testing tools . 33 3.9 Configuration tools . 34 3.10 Interpreters . 34 3.11 The Java model . 35 3.12 Exercises . 37 II Essential Concepts 38 4 Elementary Data Types 39 4.1 Integer types .
    [Show full text]
  • BRIDGE Linking Engin Ee Ring and Soci E T Y
    Summer 2009 ENERGY EFFICIENCY The BRIDGE LINKING ENGIN ee RING AND SOCI E TY The Potential of Energy Efficiency: An Overview Lester B. Lave Improving Energy Efficiency in the Chemical Industry Jeremy J. Patt and William F. Banholzer Energy Efficiency in Passenger Transportation Daniel Sperling and Nic Lutsey Building Materials, Energy Efficiency, and the American Recovery and Reinvestment Act Robin Roy and Brandon Tinianov Coming of Age in New York: The Maturation of Energy Efficiency as a Resource Paul A. DeCotis The Greening of the Middle Kingdom: The Story of Energy Efficiency in China Mark D. Levine, Nan Zhou, and Lynn Price Promoting the technological welfare of the nation by marshalling the knowledge and insights of eminent members of the engineering profession. The BRIDGE NationaL AcaDemy OF Engineering Irwin M. Jacobs, Chair Charles M. Vest, President Maxine L. Savitz, Vice President Thomas F. Budinger, Home Secretary George Bugliarello, Foreign Secretary William L. Friend, Treasurer Editor in Chief (interim): George Bugliarello Managing Editor: Carol R. Arenberg Production Assistant: Penelope Gibbs The Bridge (USPS 551-240) is published quarterly by the National Academy of Engineering, 2101 Constitution Avenue, N.W., Washington, DC 20418. Periodicals postage paid at Washington, DC. Vol. 39, No. 2, Summer 2009 Postmaster: Send address changes to The Bridge, 2101 Constitution Avenue, N.W., Washington, DC 20418. Papers are presented in The Bridge on the basis of general interest and time- liness. They reflect the views of the authors and not necessarily the position of the National Academy of Engineering. The Bridge is printed on recycled paper. © 2009 by the National Academy of Sciences.
    [Show full text]
  • Second International Computer Programming Education Conference
    Second International Computer Programming Education Conference ICPEC 2021, May 27–28, 2021, University of Minho, Braga, Portugal Edited by Pedro Rangel Henriques Filipe Portela Ricardo Queirós Alberto Simões OA S I c s – Vo l . 91 – ICPEC 2021 www.dagstuhl.de/oasics Editors Pedro Rangel Henriques Universidade do Minho, Portugal [email protected] Filipe Portela Universidade do Minho, Portugal [email protected] Ricardo Queirós Politécnico do Porto, Portugal [email protected] Alberto Simões Politécnico do Cávado e Ave, Portugal [email protected] ACM Classifcation 2012 Applied computing → Education ISBN 978-3-95977-194-8 Published online and open access by Schloss Dagstuhl – Leibniz-Zentrum für Informatik GmbH, Dagstuhl Publishing, Saarbrücken/Wadern, Germany. Online available at https://www.dagstuhl.de/dagpub/978-3-95977-194-8. Publication date July, 2021 Bibliographic information published by the Deutsche Nationalbibliothek The Deutsche Nationalbibliothek lists this publication in the Deutsche Nationalbibliografe; detailed bibliographic data are available in the Internet at https://portal.dnb.de. License This work is licensed under a Creative Commons Attribution 4.0 International license (CC-BY 4.0): https://creativecommons.org/licenses/by/4.0/legalcode. In brief, this license authorizes each and everybody to share (to copy, distribute and transmit) the work under the following conditions, without impairing or restricting the authors’ moral rights: Attribution: The work must be attributed to its authors. The copyright is retained by the corresponding authors. Digital Object Identifer: 10.4230/OASIcs.ICPEC.2021.0 ISBN 978-3-95977-194-8 ISSN 1868-8969 https://www.dagstuhl.de/oasics 0:iii OASIcs – OpenAccess Series in Informatics OASIcs is a series of high-quality conference proceedings across all felds in informatics.
    [Show full text]
  • A Auxiliary Definitions
    A Auxiliary Definitions This appendix contains auxiliary definitions omitted from the main text. Variables fun lvars :: com ⇒ vname set where lvars SKIP = {} lvars (x ::= e)={x} lvars (c1;; c2)=lvars c1 ∪ lvars c2 lvars (IF b THEN c1 ELSE c2)=lvars c1 ∪ lvars c2 lvars (WHILE b DO c)=lvars c fun rvars :: com ⇒ vname set where rvars SKIP = {} rvars (x ::= e)=vars e rvars (c1;; c2)=rvars c1 ∪ rvars c2 rvars (IF b THEN c1 ELSE c2)=vars b ∪ rvars c1 ∪ rvars c2 rvars (WHILE b DO c)=vars b ∪ rvars c definition vars :: com ⇒ vname set where vars c = lvars c ∪ rvars c Abstract Interpretation fun strip :: aacom⇒ com where strip (SKIP {P})=SKIP strip (x ::= e {P})=x ::= e © Springer International Publishing Switzerland 2014 281 T. Nipkow and G. Klein, Concrete Semantics, DOI 10.1007/978-3-319-10542-0 282 A Auxiliary Definitions strip (C 1;;C 2)=strip C 1;; strip C 2 strip (IF b THEN {P 1} C 1 ELSE {P 2} C 2 {P})= IF b THEN strip C 1 ELSE strip C 2 strip ({I } WHILE b DO {P} C {Q})=WHILE b DO strip C fun annos :: aacom⇒ a list where annos (SKIP {P})=[P] annos (x ::= e {P})=[P] annos (C 1;;C 2)=annos C 1 @ annos C 2 annos (IF b THEN {P 1} C 1 ELSE {P 2} C 2 {Q})= P 1 # annos C 1 @ P 2 # annos C 2 @ [Q] annos ({I } WHILE b DO {P} C {Q})=I # P # annos C @ [Q] fun asize :: com ⇒ nat where asize SKIP = 1 asize (x ::= e)=1 asize (C 1;;C 2)=asize C 1 + asize C 2 asize (IF b THEN C 1 ELSE C 2)=asize C 1 + asize C 2 + 3 asize (WHILE b DO C )=asize C + 3 definition shift :: (nat ⇒ a) ⇒ nat ⇒ nat ⇒ a where shift f n =(λp.
    [Show full text]
  • Awk Short Intro
    awk short intro Robert Kofler awk • scripng language for reformang text files or extracng informaon from text files • good performance with large text files ⇒ thus “awk” is like PCR for NGS data analysis Why awk: very powerful (you can answer a lot of NGS related quesons with a simple awk command) easy to learn good performance with large text files may be used with other Unix‐command (pipe) Our input file basics • Name: Alfred Aho, Peter Weinberger, Brian Kernighan • How to use awk awk ‘command’ input_file.txt or cat input_file.txt | awk ‘command’ Let’s start: awk ‘{print $1}’ sample.txt cat sample.txt| awk ‘{print $1}’ Structure of awk command full structure of a awk command: awk ‘BEGIN{command}condition{command}END{command}’ # BEGIN{command} => execute this command at the beginning # condition{command} => MOST IMPORTANT PART, will be executed for every line in the file! # END{command} => execute this command at the end example: awk ‘BEGIN{print “File start”}$1==“2L”{print $0}END{print “End of file”}’ sample.txt Most things are oponal shortest example possible awk ‘’ sample.txt => not doing anything awk ‘$1’ sample.txt => prints line if $1 is not empty # above, we are only using ‘condition{command}’ # we are not using ‘BEGIN{command}’ and ‘END{command}’ default for ‘condion{command}’ is the following ‘condion’ => ‘condion{print $0}’ awk ‘$1’ sample.txt # is per default using the following command: awk ‘$1{print $0}’ # {print $0} is the default for the loop!! # {print $0} just means print the line Now some more meaningful condions awk ‘$1==“2L”’
    [Show full text]
  • Assembling a Prehistory for Formal Methods: a Personal View Thomas Haigh [email protected]
    Assembling A Prehistory for Formal Methods: A Personal View Thomas Haigh [email protected] University of Wisconsin—Milwaukee & Siegen University www.tomandmaria.com This is a preprint copy. Please quote and cite the final version, which will appear in a special issue of Formal Aspects of Computing devoted to historical work. Thanks to Cliff Jones and the anonymous reviewers for their encouragement and feedback on earlier drafts of this paper. Preprint Draft Haigh – Assembling a History for Formal Methods 2 Although I was pleased to be asked to contribute something to this volume I have a confession to make: I have never studied the history of formal methods. So this is not going to be a history of formal methods as much as a reflection on how such a story might be written. My plan is to triangulate from my personal experiences as a computer science student a quarter century ago, my Ph.D. training as a historian of science and technology, and my subsequent career researching and writing about various aspects of the history of computing. The fact that, despite a general familiarity with the literature on the history of computing, I don’t have a better grasp of the history of formal methods tells us a lot about the need for this special issue. Most of the history is so far locked up in the heads of participants, which is not a convenient place for the rest of us to find it. Stories written by participants or people with a personal connection to the events described are not usually the last word on historical events, but they are a vital starting point.
    [Show full text]
  • Appendix B: Annotated Bibliography
    Appendix B: Annotated Bibliography There are a wide variety of texts available for those who are interested in learning more about assem- bly language or other topics this text covers. The following is a partial list of texts that may be of interest to you. Many of these texts are now out of print. Please consult your local library if you cannot find a particu- lar text at a bookstore. Microprocessor Programming for Computer Hobbyists Neill Graham TAB books ISBN 0-8306-6952-3 1977 This book provides a gentle introduction to data structures for computer hobbyists. Although it uses the PL/M programming language, many of the concepts apply directly to assembly language programs. IBM Assembler Language and Programming Peter Able Prentice-Hall ISBN 0-13-448143-7 1987 A college text book on assembly language. Contains good sections on DOS and disk formats for earlier versions of DOS. MS-DOS Developer’s Guide John Angermeyer and Keven Jaeger Howard W. Sams & Co. ISBN 0-672-22409-7 An excellent reference book on programming MS-DOS. Compilers: Principles, Techniques, and Tools Alfred Aho, Ravi Sethi, and Jeffrey Ullman Addison Wesley ISBN 0-201-10088-6 1986 The standard text on compiler design and implementation. Contains lots of material on pattern matching and other related subjects. C Programmer’s Guide to Serial Communications Joe Campbell Howard W. Sams & Co. ISBN 0-672-22584-0 An indispensible guide to serial communications. Although written specifically for C programmers, the material applies equally well to assembly language programmers. The MS-DOS Encyclopedia Ray Duncan, General Editor & various authors Microsoft Press ISBN 1-55615-049-0 An excellent description of MS-DOS programming.
    [Show full text]
  • TECHNOLOGY MADE LEGIBLE a Cultural Study of Software As A
    TECHNOLOGY MADE LEGIBLE A Cultural Study of Software as a Form of Writing in the Theories and Practices of Software Engineering Federica Frabetti Goldsmiths College, University of London Submitted for the degree of PhD 2009 Abstract My dissertation proposes an analytical framework for the cultural understanding of the group of technologies commonly referred to as 'new' or 'digital'. I aim at dispelling what the philosopher Bernard Stiegler calls the 'deep opacity' that still surrounds new technologies, and that constitutes one of the main obstacles in their conceptualization today. I argue that such a critical intervention is essential if we are to take new technologies seriously, and if we are to engage with them on both the cultural and the political level. I understand new technologies as technologies based on software. I therefore suggest that a complex understanding of technologies, and of their role in contemporary culture and society, requires, as a preliminary step, an investigation of how software works. This involves going beyond studying the intertwined processes of its production, reception and consumption - processes that typically constitute the focus of media and cultural studies. Instead, I propose a way of accessing the ever present but allegedly invisible codes and languages that constitute software. I thus reformulate the problem of understanding software-based technologies as a problem of making software legible. I build my analysis on the concept of software advanced by Software Engineering, a technical discipline born in the late 1960s that defines software development as an advanced writing technique and software as a text. This conception of software enables me to analyse it through a number of reading strategies.
    [Show full text]
  • Nbs Programming Environment Workshop Report
    of Commerce Computer Science National Bureau of Standards and Technology NBS NBS Special Publication 500-78 PUBLICATIONS NBS Programming * Of '"StAU Environment Worksiiop Report NATIONAL BUREAU OF STANDARDS The National Bureau of Standards' was established by an act of Congress on March 3, 1901. The Bureau's overall goal is to strengthen and advance the Nation's science and technology and facilitate their effective application for public benefit. To this end, the Bureau conducts research and provides: (1) a basis for the Nation's physical measurement system, (2) scientific and technological services for industry and government, (3) a technical basis for equity in trade, and (4) technical services to promote public safety. The Bureau's technical work is per- formed by the National Measurement Laboratory, the National Engineering Laboratory, and the Institute for Computer Sciences and Technology. THE NATIONAL MEASUREMENT LABORATORY provides the national system of physical and chemical and materials measurement; coordinates the system with measurement systems of other nations and furnishes essentia! services leading to accurate and uniform physical and chemical measurement throughout the Nation's scientific community, industry, and commerce; conducts materials research leading to improved methods of measurement, standards, and data on the properties of materials needed by industry, commerce, educational institutions, and Government; provides advisory and research services to other Government agencies; develops, produces, and distributes Standard
    [Show full text]