CMPE 152 Compiler Design

Similar documents
CMPE 152 Compiler Design

CMPE 152 Compiler Design

CS/SE 153 Concepts of Compiler Design

CS/SE 153 Concepts of Compiler Design

CMPE/SE 135 Object-Oriented Analysis and Design

CMPE 280 Web UI Design and Development

CMPE 280 Web UI Design and Development

San José State University College of Science/Department of Computer Science CS 152, Programming Language Paradigms, Section 03/04, Fall, 2018

CMPE 180A Data Structures and Algorithms in C++

San José State University College of Science/Department of Computer Science CS152, Programming Paradigms, Sections 1 & 2 Spring Semester, 2018

San José State University College of Science/Department of Computer Science CS152, Programming Paradigms, Sections 3 & 4, Fall Semester, 2016

San José State University College of Science/Department of Computer Science CS152, Programming Paradigms, Sections 1 & 2, Fall Semester, 2017

Compilers. Computer Science 431

San José State University Computer Science Department CS49J, Section 3, Programming in Java, Fall 2015

San José State University Department of Computer Science CS166, Information Security, Section 1, Fall, 2018

San José State University Department of Computer Science CS 166 / SE 166, Information Security, Section 4, spring, 2017

San José State University Department of Computer Science CS049J, Programming in Java, Section 2, Fall, 2016

San José State University Department of Computer Science CS-144, Advanced C++ Programming, Section 1, Fall 2017

Philadelphia University Faculty of Information Technology Department of Computer Science --- Semester, 2007/2008. Course Syllabus

San José State University Department of Computer Science CS151, Section 04 Object Oriented Design Spring 2018

San José State University Department of Computer Science CS-174, Server-side Web Programming, Section 2, Spring 2018

San Jose State University College of Science Department of Computer Science CS151, Object-Oriented Design, Sections 1,2 and 3, Spring 2017

San Jose State University - Department of Computer Science

ECE573 Introduction to Compilers & Translators

San José State University Department of Computer Science CS151, Object Oriented Design, Section 04, Fall, 2016 (42968)

San Jose State University College of Science Department of Computer Science CS151, Object-Oriented Design, Sections 1, 2, and 3, Spring 2018

Compilers for Modern Architectures Course Syllabus, Spring 2015

AE Computer Programming for Aerospace Engineers

San José State University Computer Science CS 122 Advanced Python Programming Spring 2018

San José State University Department of Computer Science CS-144, Advanced C++ Programming, Section 1, Spring 2018

B. Subject-specific skills B1. Problem solving skills: Supply the student with the ability to solve different problems related to the topics

CS Compiler Construction West Virginia fall semester 2014 August 18, 2014 syllabus 1.0

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers

San Jose State University College of Science Department of Computer Science CS185C, Introduction to NoSQL databases, Spring 2017

INST Database Design and Modeling - Section 0101 Spring Tentative Syllabus

San José State University Computer Science Department CS157A: Introduction to Database Management Systems Sections 5 and 6, Fall 2015

San Jose State University College of Science Department of Computer Science CS185C, NoSQL Database Systems, Section 1, Spring 2018

CS 241 Data Organization using C

HOLY ANGEL UNIVERSITY COLLEGE OF INFORMATION AND COMMUNICATIONS TECHNOLOGY COMPILER THEORY COURSE SYLLABUS

San José State University College of Science / Department of Computer Science Introduction to Database Management Systems, CS157A-3-4, Fall 2017

Computer Science Technology Department

General Course Information. Catalogue Description. Objectives

KOMAR UNIVERSITY OF SCIENCE AND TECHNOLOGY (KUST)

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers

Translator Design CRN Course Administration CMSC 4173 Spring 2017

Principles of Compiler Construction ( )

ECE Introduction to Compilers and Translation Engineering

Course and Contact Information. Course Description. Course Objectives

INF 315E Introduction to Databases School of Information Fall 2015

Course and Contact Information. Course Description. Course Objectives

CSCI 565 Compiler Design and Implementation Spring 2014

CS120 Computer Science I. Instructor: Jia Song

CSCI 201L Syllabus Principles of Software Development Spring 2018

ISM 324: Information Systems Security Spring 2014

San Jose State University College of Science Department of Computer Science CS151, Object-Oriented Design, Sections 1 and 2, Spring 2016

THE UNIVERSITY OF TEXAS AT AUSTIN MIS373 e-discovery and Digital Forensics SPRING 2015 Unique#: (03665) VERSION: 2_011718

CNG 140 C Programming. Syllabus. Course Info Fall Semester. Catalog Description

University of Maryland at College Park Department of Geographical Sciences GEOG 477/ GEOG777: Mobile GIS Development

CMPE 180A Data Structures and Algorithms in C++ Spring 2018

San José State University Department of Computer Science CS158B, Computer Network Management, Section 1, Fall 2016

ab Houston Community College

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers

CS 3270 Mobile Development for Android Syllabus

BOSTON UNIVERSITY Metropolitan College MET CS342 Data Structures with Java Dr. V.Shtern (Fall 2011) Course Syllabus

CoSci 440 SYLLABUS Programming in C++ INSTRUCTOR Mari Rettke cell SECTION : and 13345

BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE, Pilani Pilani Campus Instruction Division

Syllabus Revised 01/03/2018

Principles of Compiler Construction ( )

Syllabus -- CIS Computer Maintenance / A+ Certification

CS 415 Midterm Exam Spring 2002

CSc 2310 Principles of Programming (Java) Jyoti Islam

Translator Design CRN Course Administration CMSC 4173 Spring 2018

CSC 111 Introduction to Computer Science (Section C)

Computer Science Technology Department

Spring 2018 El Camino College E. Ambrosio. Course Syllabus

BRAZOSPORT COLLEGE LAKE JACKSON, TEXAS SYLLABUS COSC 1320: INTRODUCTION TO C++ PROGRAMMING COMPUTER TECHNOLOGY & OFFICE ADMINISTRATION DEPARTMENT

GUJARAT TECHNOLOGICAL UNIVERSITY

Syllabus of ENPM 691: Secure Programming in C

Course Syllabus Internal Control And Auditing ACNT 2331

Spring CISM 3330 Section 01D (crn: # 10300) Monday & Wednesday Classroom Miller 2329 Syllabus revision: #

CS 241 Data Organization. August 21, 2018

Computer Science Technology Department

Introduction to Programming System Design CSCI 455x (4 Units)

COURSE SYLLABUS FOR. COMP-297 Web Page Design: Adobe Dreamweaver

ITSY Information Technology Security Course Syllabus Spring 2018

Oklahoma State University Institute of Technology Face-to-Face Common Syllabus Fall 2017

ESET 349 Microcontroller Architecture, Fall 2018

Compiling Techniques

Computer Science Technology Department

CMSC 132: Object-Oriented Programming II. Administrivia

CPS352 Database Systems Syllabus Fall 2012

G.PULLAIH COLLEGE OF ENGINEERING & TECHNOLOGY

EECE.2160: ECE Application Programming Spring 2019

Evaluation Scheme L T P Total Credit Theory Mid Sem Exam

INFSCI 1017 Implementation of Information Systems Spring 2017

CS 3304 Comparative Languages. Lecture 1: Introduction

Syllabus COSC-051-x - Computer Science I Fall Office Hours: Daily hours will be entered on Course calendar (or by appointment)

CS 3230 Object Oriented UI Development With Java Syllabus

CS 235AM, Mobile Application Development: Android Spring 2016

A: 90% - 100% B: 80% - <90% C: 70% - <80% D: 60% - <70% F: < 60% Important Dates:

Transcription:

San José State University Department of Computer Engineering CMPE 152 Compiler Design Section 1 (Class) Sections 2 and 3 (Labs) Spring 2019 Course and Contact Information Instructor: Ron Mak Office Location: ENG 250 Email: ron.mak@sjsu.edu Website: http://www.cs.sjsu.edu/~mak/ Office Hours: TuTh 3:00-4:00 PM Class Days/Time: TuTh 4:30-5:20 PM Labs Days/Time: Section 2: Tu 6:00 8:45 PM Section 3: Th 6:00 8:45 PM Classrooms: Class: Boccardo Business Center BBC 320 Labs: ENG 206 Prerequisites: CMPE 126, CMPE 102 (both with grade of "C-" or better). Course Format This course will be taught primarily via classroom presentations. Faculty Web Page and Canvas Course materials, syllabus, assignments, grading criteria, exams, and other information will be posted at my faculty website at http://www.cs.sjsu.edu/~mak and on the Canvas Learning Management System course login website at http://sjsu.instructure.com. You are responsible for regularly checking these websites to learn of any updates. You can find Canvas video tutorials and documentations at http://ges.sjsu.edu/canvas-students Course Catalog Description Principles of lexical analysis, finite state automata and parsing; issues of variable declarations, variable types, control statements, function calls, nested scopes and efficient assembler target code. CMPE 152 Compiler Design, Spring 2019, Ron Mak Page 1 of 7

Course Goals This course will concentrate on practical aspects of compiler construction, programming language design, and engineering a large, complex software application. Compiler construction and language design. Design and build a working compiler for a programming language that you invented. Write sample programs in your language and then compile them into executable machine code that you can run. Software engineering. Employ the best practices of object-oriented design and team-based software engineering. A compiler is a large, complex program! Managing the development of such a program requires learning critical job skills that are highly desired by employers. Course Learning Outcomes (CLO) Upon successful completion of this course, students will be able to: CLO 1: Develop a scanner and a parser for a programming language. CLO 2: Perform syntactic and semantic analyses of source programs. CLO 3: Generate symbol tables and intermediate code for source programs. CLO 4: Develop an interpreter that executes a source program in a suitable runtime environment. CLO 5: Design the grammar for a programming language and feed it into a compiler-compiler. CLO 6: Develop a compiler that translates a source program into executable machine code. CLO 7: Engineer a large, complex software application. Required Texts Title: Author: Publisher: ISBN: Source files: Title: Author: Publisher: ISBN: Writing Compilers and Interpreters: A Software Engineering Approach, 3 rd edition Ronald Mak Wiley Publishers, Inc., 2009 978-0-470-17707-5 http://www.cs.sjsu.edu/~mak/cmpe152/sources (both Java and C++ source files are available) The Definitive ANTLR 4 Reference, 2 nd edition Terence Parr Pragmatic Bookshelf, 2013 978-1934356999 http://www.antlr.org We will use the ANTLR 4 compiler-compiler during the second half of the course, so you won t need the ANTLR text until then. ANTLR 4 can generate compiler components written in either Java or C++. We will use Pascal as an example source language. These online Pascal tutorials are helpful: Pascal Tutorial looks very good. It even has an online compiler. Learn Pascal also looks good, although it doesn't appear to cover set types. Some online websites to compile and run Pascal programs: http://rextester.com/l/pascal_online_compiler https://www.tutorialspoint.com/compile_pascal_online.php https://www.jdoodle.com/execute-pascal-online CMPE 152 Compiler Design, Spring 2019, Ron Mak Page 2 of 7

Software to Install You should install and use an interactive development environment (IDE) such as Eclipse. To develop a compiler for your language, you will need to download and install the ANTLR 4 package and its Eclipse plugin, and then modify them to generate the compiler components in C++. This is relatively straightforward on the Mac and Linux platforms. However, the Windows platform has significant compatibility challenges. Therefore, if you re on Windows, you should download and install the VirtualBox virtual machine manager, and then install and run Ubuntu (a variant of Linux) in a virtual machine. Some useful tutorials: Install and Configure VirtualBox on Windows http://www.cs.sjsu.edu/~mak/tutorials/installvirtualbox.pdf Install and Configure Ubuntu on a VirtualBox Virtual Machine http://www.cs.sjsu.edu/~mak/tutorials/installubuntu.pdf Install and Configure Eclipse on Ubuntu for Java and C++ Development http://www.cs.sjsu.edu/~mak/tutorials/installeclipse.pdf Install and Configure ANTLR 4 on Ubuntu http://www.cs.sjsu.edu/~mak/tutorials/installantlr4.pdf Install and Configure ANTLR 4 for C++ http://www.cs.sjsu.edu/~mak/tutorials/installantlr4cpp.pdf Course Requirements and Assignments You should have good C++ programming skills and be familiar with software development tools such as Eclipse. You will form project teams of four students each. Team membership is mandatory for this class. The teams will last throughout the semester. Once the teams are formed, you will not be allowed to move from one team to another, so form your teams wisely! Weekly team assignments during the first part of the semester will provide practice with compiler design techniques and give students experience adding new features to a large legacy code base. Each student on a team will receive the same score for each team assignment. Each team will submit its assignments into Canvas, where the rubric for scoring each will be displayed. Each assignment and project will be worth up to 100 points. Late assignments will lose 20 points and an additional 20 points for each 24 hours after the due date. This is a challenging course that will demand much of your time and effort throughout the semester. The university s syllabus policies: University Syllabus Policy S16-9 at http://www.sjsu.edu/senate/docs/s16-9.pdf. Office of Graduate and Undergraduate Program s Syllabus Information web page at http://www.sjsu.edu/gup/syllabusinfo/ Success in this course is based on the expectation that students will spend, for each unit of credit, a minimum of 45 hours over the length of the course (normally 3 hours per unit per week with 1 of the hours used for lecture) for instruction or preparation/studying or course related activities including but not limited to internships, labs, clinical practica. Other course structures will have equivalent workload expectations as described in the syllabus. CMPE 152 Compiler Design, Spring 2019, Ron Mak Page 3 of 7

Team compiler project In addition to the team assignments, each student team will work on a compiler project throughout the semester. Each team will develop a working compiler for a newly invented language or for an existing language. Teams will be able to write, compile, and execute programs written in their invented or chosen languages. Each student on a team will receive the same score for the team project. Each project involves: Invent a new programming language or choose a subset of an existing language. Develop a grammar for the language. Generating a compiler for the language using the ANTLR compiler-compiler. Other components may be borrowed from the compiler code given in the class. A minimally acceptable compiler project has at least these features: Two data types with type checking. Basic arithmetic operations with operator precedence. Assignment statements. A conditional control statement (e.g., IF). A looping control statement. Procedures or functions with calls and returns. Parameters passed by value or by reference. Basic error recovery (skip to semicolon or end of line). Nontrivial sample programs written in the source language. Generate Jasmin assembly code that can be successfully assembled. Execute the resulting.class file. No crashes (e.g., null pointer exceptions). Each team will write a report (5-10 pp.) that includes: A high-level description of the design of the compiler with UML diagrams of the major classes. The grammar for your source language, either as syntax diagrams or in BNF. Code templates that show the Jasmin code your compiler generates for some key constructs of the source language. Exams The midterm and final examinations will be closed book. There can be no make-up midterm examination unless there is a documented medical emergency. Make-up final examinations are available only under conditions dictated by University regulations. The exams will test understanding (not memorization) of the material taught during the semester and now well each of you participated in your team assignments and project. Academic Integrity Major exams in this class may be video recorded to ensure academic integrity. The recordings will only be viewed if there is an issue to be addressed. Under no circumstances will the recordings be publicly released. CMPE 152 Compiler Design, Spring 2019, Ron Mak Page 4 of 7

Grading Information Individual total scores will be computed with these weights: 30% Assignments* 35% Compiler project* 15% Midterm exam** 20% Final exam** * team scores ** individual scores Course grades will be based on a curve. Per CMPE Department policy, the median total score will earn a B. Approximately one third of the class will earn higher grades, and another one third will earn lower grades. Postmortem report At the end of the semester, each student must also turn in a short (under 1 page) individual postmortem report that includes: A brief description of what you learned in the course. An assessment of your accomplishments for your team assignments and design project. An assessment of each of your other project team members. Only the instructor will see these reports. How your teammates evaluate you may affect your course grade. Classroom Protocol It is very important for each student to attend classes and to participate. Mobile devices in silent mode, please. University Policies Per University Policy S16-9, university-wide policy information relevant to all courses, such as academic integrity, accommodations, etc. will be available on Office of Graduate and Undergraduate Program s Syllabus Information web page at http://www.sjsu.edu/gup/syllabusinfo/. CMPE 152 Compiler Design, Spring 2019, Ron Mak Page 5 of 7

CMPE 152 Compiler Design Section 1 (Class) Sections 2 and 3 (Labs) Spring 2019 Course Schedule (subject to change with fair notice) WCI = Writing Compilers and Interpreters, 3rd edition ANTLR = The Definitive ANTLR 4 Reference, 2 nd edition Week Dates Topics Readings 1 Jan 24 Overview of the course What are compilers and interpreters? Form programming teams 2 Jan 29 A software framework for compilers and interpreters Jan 31 3 Feb 5 Feb 7 4 Feb 12 Feb 14 5 Feb 19 Feb 21 6 Feb 26 Feb 28 7 Mar 5 Mar 7 8 Mar 12 Mar 14 9 Mar 19 Mar 21 Scanning (lexical analysis) Basic scanning algorithm Symbol table management Top-down recursive-descent parsing Syntax diagrams Parse assignment statements and expressions Intermediate code (parse trees) Interpret assignment statements and expressions Parsing control statements Parser error handling Interpret control statements Runtime error handling Scope and the symbol table stack Parsing declarations Parsing declarations, cont d Semantic actions and type checking Parse programs, procedures, and functions Parse procedure and function calls Runtime memory management The runtime stack and activation frames Pass parameters by value and by reference Midcourse review Midterm exam Thursday, March 14 (75 min.) A simple DFA scanner BNF grammars for programming languages The ANTLR compiler-compiler WCI 1, 2, 3 WCI 4 WCI 5 WCI 5 WCI 6, 7 WCI 8, 9 WCI 9, 10 WCI 11, 12 WCI 12 ANTLR 1-4 CMPE 152 Compiler Design, Spring 2019, Ron Mak Page 6 of 7

Week Dates Topics Readings 10 Mar 26 Mar 28 Apr 1-5 11 Apr 9 Apr 11 12 Apr 16 Apr 18 13 Apr 23 Apr 25 14 Apr 30 May 2 15 May 7 May 9 Final Exam Tuesday, May 21 Generate a scanner and a parser with ANTLR ANTLR listener and visitor interfaces Spring break Pcl, a tiny subset of Pascal ANTLR-generated compiler components for Pcl The Java Virtual Machine (JVM) architecture Jasmin assembly language Code templates and code generation Pcl2 code generation example Code for expressions Code for assignment statements Code for control statements Code for procedure and function calls Code to call System.out.printf() Code for string operations Code for arrays and records The Pascal runtime library Code to pass parameters by value and by reference Compiled vs. interpreted code Context-free vs. context-sensitive grammars Bottom-up parsing with yacc and lex Code optimization Runtime memory management Garbage collection algorithms Team compiler demos (optional) Time: 2:45-5:00 PM Room: BBC 320 ANTLR 5, 6 WCI 15 ANTLR 7, 8 WCI 16, 17 ANTLR 9 WCI 18 Labs Dates Activities Jan 24, 29 Work on Assignment #1: Write simple Pascal programs Jan 31, Feb 5 Install development environment; compile and run Chapter2cpp sources Feb 7, 12 Work on Assignment #2: C++ scanner Feb 14, 19 Work on Assignment #3: New WHEN control statement Feb 21, 26 Complete Assignment #3 Feb 28, Mar 5 Work on Assignment #4: New built-in complex type Mar 7, 12 Complete Assignment #4: Mar 14, 19 Install ANTLR 4 Mar 21, 26 Work on Assignment #5: ANTLR 4 grammar Mar 28, Apr 9 Work on Assignment #5 Apr 11, 16 Complete Assignment #5 Apr 18, 23 Work on Assignment #6: Code generation Apr 25, 30 Work on Assignment #6 May 2, 7 Complete Assignment #6 May 9 Optional lab CMPE 152 Compiler Design, Spring 2019, Ron Mak Page 7 of 7