Syllabus


Introduction

I invite you to pull back the curtain surrounding the compiler ‘black box.’ Since CS 139/149, you’ve used a compiler to prepare your computer programs for execution, but do you know how that process works under the hood? How does the compiler take a human-readable program and turn it into low-level machine code that a CPU can execute? In this class, we will explore the techniques behind automatic translation (the task of a compiler). You will learn new algorithms and data structures, engaging in fun activities and software development projects to bring these topics alive and solidify your understanding of them.

After taking the course, you will be able to describe the inner workings of a modern compiler and the interesting algorithms that enable automated translation. You will have the skills necessary to write a compiler of your own, and you will have a significant large-scale software project development experience to discuss in job interviews. The skills acquired in this course will make you a more effective computer scientist and provide continuing benefits throughout your career.

Course Plan

Each week will begin with a review/orientation lecture where I will tie together the previous topic with the next one and provide a basic introduction to the new material. Armed with this introduction, you will perform an initial reading before taking a diagnostic/formative reading quiz. The following class period will consist of a mini-lecture and discussion to address any points of confusion. You will then have another opportunity to re-read the material in more detail to prepare you for an in-class activity that will provide a opportunity to engage with the material in format similar to later test/exam assessments. These two weekly assessments (quizzes and activities) are intended to be mostly formative, helping you engage with the material for more effective learning and preparing you for the midterms and the final exam (which are summative).

The semester-long project in this course is to build a compiler for a very simple programming language ("Decaf"). There will be approximately six subproject submissions throughout the semester. This project will assess nearly all of the course learning objectives. You may work by yourself on the project or in teams of two (i.e., one other student). If you work with another student, you must clearly declare this, and your project submissions must be identical. The project itself is summative (showing me whether you can apply theory-based course content to build an actual software product).

All students in this course will also conduct a code review for each project, mirroring standard software development processes in industry. You will be given someone else’s submission (possibly two of them) and asked to read it and offer constructive criticism. You will be graded on the quality of your code review.

Objectives and Expectations

By the end of the course, you should be able to do the following:

  • Identify and discuss the technical and social challenges of building a large software system such as a compiler.
  • Develop and analyze formal descriptions of computer languages.
  • Apply finite automata theory to build recognizers (lexers) for regular languages.
  • Apply pushdown automata theory to build recognizers (parsers) for context-free languages.
  • Evaluate the role of static analysis in automated program translation.
  • Apply tree traversals to convert a syntax tree to low-level code.
  • Discuss the limitations that an architecture or execution environment places on the generation of machine code.
  • Describe common optimizations and evaluate the tradeoffs associated with good optimization.

Course Textbook

Engineering a Compiler, 2nd Edition (Errata)
Keith Cooper and Linda Torczon

Although the dragon book by Aho, Lam, Sethi, and Ullman is the classic compilers textbook, it is a bit dense and theory-heavy. We will be using an alternate text by Cooper and Torczon that still contains a good amount of theory but is also more focused on the practical and software engineering aspects of compiler implementation. It has clean, concise descriptions of everything that we will cover in the course and lots of illustrative diagrams and examples.

The textbook is available from the campus bookstore for $98 and from Amazon for $75 (new) or $60 (used). You are welcome to obtain the book from any legal source, and there should be a reserve copy in the library (East Campus).

Textbook Cover

Grading Criteria

You are responsible for all material discussed in lecture and discussion section and posted on the class web page, including announcements, deadlines, policies, etc.

Your final course grade will be determined according to the following percentages:

Reading Quizzes 10%
In-class Activities 10%
Programming Projects 30%
Midterm Exams 30%
Final Exam 20%

Final course letter grades may be curved at the end of the semester based on each student's overall performance for all coursework. Other factors that may influence a curve are your general performance trend over the semester (improving or degrading) and your general investment in the course (attendance and participation). These are aspects of the course for which I do not give formal grades, but they may factor into your final letter grade assignment.

If you believe I have made an error while grading your work or calculating your final score, please bring it to my attention after class or during office hours. If I determine that there has been a simple mistake, I will fix it immediately and no formal request is necessary.

If you believe an exam question or assignment has been graded unfairly, you must submit a verbal or written formal request for a regrade. Such requests must be submitted within one week of when the assignment in question is returned to you. Any coursework submitted for reconsideration may be regraded in its entirety, which could result in a lower score if warranted.

Completing the programming assignments is an essential part of the course. Therefore, I reserve the right to fail any student who does not make a good-faith attempt on all course projects, regardless of the student's performance or scores on the other coursework.

Instructor Contact Info

Please post generic questions to Piazza, where other students may answer and/or benefit from my answers. My email is lam2mo at the standard domain. My office is in ISAT/CS 227, and my office hours are posted on the main course page.

I am also sometimes available outside office hours by appointment; if you wish to make an appointment, please check the public calendar on my home page to find a several candidate times that work for you and send me an email.

I do my best to respond to emails in a timely fashion. You may reasonably expect a response to an email inquiry within 24-48 hours during the week; feel free to re-send an email if you do not receive a response in that time frame. However, I do not guarantee responses over the weekend, and I do not guarantee any response at all to email inquiries sent during the last 24 hours before a project due date. This policy exists to encourage timely work on projects.

Course Policies

Important announcements will be made in class and/or on the class website (including Piazza). Please make it a habit to check the web page and Piazza daily. I usually make an effort to broadcast announcements when the schedule changes, but you alone are responsible for missed assignment due dates. Do not rely on the Canvas sidebar to keep track of course assignments for you; it is not always reliable.

Although every effort has been made to be complete and accurate, unforeseen circumstances arising during the semester could require the adjustment of any material given here. Consequently, given due notice to students, I reserve the right to change any information on this syllabus or in other course materials.

You are permitted to use course materials for your own personal use only. Course materials may not be distributed publicly or provided to others (excepting other students in the course), in any way or format unless explicitly allowed.

Attendance and Participation

You must attend class during the first week of the semester in order to "claim" your seat in the class. To assure that the maximum number of students can benefit from the course, I reserve the right to drop any student who does not attend the first two classes of the semester. This frees up seats for students on the waitlist. If you have mitigating circumstances (i.e., health or travel issues) that prevent you from attending a class the first week, please notify me BEFORE that class time.

After the first week, attendance is not mandatory, and I generally do not give grades purely based on attendance. I view my students' time as valuable, and my goal as a teacher is to make class attendance and participation well worth the time investment for you. I strongly encourage you to attend every class session and participate fully in order to derive the maximum benefit of this course. If you believe that there is something I could change about the way I am handling the course in order to improve its effectiveness for you, please let me know via email or office hours.

You should also be aware that I do occasionally give graded quizzes or graded group work assignments during class periods. In some cases, I will notify you in advance about these quizzes or assignments, but I do reserve the right to administer them unannounced at my discretion.

It is very important to me that all students feel secure and included in my courses. I also believe that a diversity of background and experiences enriches the classroom. If at any time you have a concern about my classroom environment or your classmates, please talk to me immediately so that we can address the situation. If you wish to be called by anything other than what is listed in MyMadison (e.g., nicknames, pronouns, etc.), please let me know. If you wish to communicate with me without other students present, please email me to set up an appointment.

Please silence your cell phone while class is in session. If you have a laptop or tablet, you are encouraged to bring it to class and use it to work along with programming examples and exercises. Mute the volume to avoid unintended interruptions, and do not use any electronic devices for activities that may distract other students. Repeated violations of this policy may result in disciplinary action or a grade penalty in the course.

I strongly encourage you to check the main website and the Piazza web forum regularly for important announcements (usually regarding programming projects). You may also use the Piazza forum to ask general questions of interest to the class as a whole (e.g., administrative issues or project clarification questions) as well as to offer each other general advice on class assignments. However, do not post any information that would violate the university academic integrity policy. If you are unsure about this, please email me for approval before you post.

As a college student, there may be times when personal stressors interfere with your academic performance and/or negatively impact your daily life. If you or someone you know is experiencing mental health challenges at James Madison University, please connect with the Counseling Center (CC) located within the Student Success Center on the 3rd floor. You can learn more about available CC services by visiting their website or calling the Center (540-568-6552). Their services are free and confidential. Other available support resources to consider on campus include, but are not limited to the: Office of the Dean of Students, Health Center, Learning Strategies Instruction, and the Office of Disability Services.

Programming Projects

Projects must be submitted electronically following the instructions given in class and on the website. Projects may not be submitted by any other means (e.g., do not email your projects to me unless I request that). It is your responsibility to test your program and verify that it works properly before submitting it.

All projects are due at 23:59 (11:59pm) on the day indicated on the project assignment unless noted otherwise.

Projects may be submitted up to 72 hours late for a 10% penalty per 24-hour period. For example, a submission that would have earned 90 points in an on-time submission will earn 90 x 0.90 = 81 points if submitted up to 24 hours late, or 90 x 0.80 = 72 points if submitted up to 48 hours late. If you make multiple submissions, I will typically grade the latest submission. If you wish me to grade a different submission, you must indicate this before the 72-hour late period is over.

Regardless of the above policy, I reserve the right to refuse to grade any projects submitted after the beginning of the second class period following the project deadline, because I may discuss the solution in class.

Project extensions will not generally be granted due to server congestion, system problems, network problems, power outages, etc., so do not wait to submit a project until the night it is due. No consideration in grading will be made for errors made in transferring files or submitting the wrong version of your project. Having a working, non-submitted version will not count; only submitted code will be be counted. I strongly urge you to use version control software and/or keep redundant backups of your work to avoid data loss.

You will be responsible for developing your own techniques for testing your projects before submitting it. I will grade your projects based on test cases not provided to you in advance. Because grading may be done automatically, you must follow the project specification exactly.

Your code will be graded on a combination of correctness, completeness, documentation, and code style. If you have any questions as to what constitutes good documentation or code style, be sure to ask ahead of time or refer to any provided style guide.

Any "hard coding" in a project assignment will result in a score of zero for that project, and is considered a bad-faith effort. Hard coding refers to attempting to make a program appear as if it works correctly, when in fact it does not. One example of hard coding would be printing the desired output instead of computing it. If you have any questions as to what constitutes hard coding for a particular assignment, be sure to ask ahead of time.

Adding and Dropping the Course

Students are responsible for adding and dropping courses. Please consult the appropriate academic calendar for the exact deadlines. I will not give "WP" or "WF" grades to students requesting a drop after the deadline except in extraordinary circumstances.

Academic Honesty

You are expected to comply with the JMU Honor Code as stated in the Student Handbook and available from the Honor Council website on all assignments, projects, and exams.

Consulting with other students about problems and solutions is not necessarily a violation of the honor code, depending on the particular assignment. All final work turned in for an assignment must be your own unless it is a group project. In particular, you may not share any source or binary code on programming assignments unless the project specification explicitly allows it. This includes but is not limited to: direct file copying, detailed verbal descriptions, screen captures, and photos. If you are in doubt about whether something is an honor code violation, please contact me immediately.

If I find evidence of a violation of the honor code, I will bring the matter to the attention of the involved individuals via email and request a face-to-face meeting. As per section IV of the honor code, first time student offenders may agree that a violation has occurred and accept an appropriate penalty by submitting an "Informal Resolution Agreement Form" to the honor council. If the student is not a first-time offender or if there is disagreement about the violation or penalty, the matter will be referred to the honor council under section V of the honor code.

Disability Accommodations

If you need an accommodation based on the impact of a disability, you must contact the Office of Disability Services if you have not previously done so. Disability Services will provide you with an Access Plan letter that will verify your need for services and make recommendations for accommodations to be used in the classroom. Once you have shown me this letter, we will sit down and review the course requirements, your disability characteristics, and your requested accommodations to develop an individualized plan appropriate for this course. I will not make any accommodations without the appropriate documentation, as I am not qualified to diagnose disabilities.

Excused Absences

Besides the policies in this syllabus, the University's policies apply during the semester. Various policies that may be relevant appear in the Undergraduate Catalog.

Excused absences will be granted at my discretion and only with appropriate documentation. Please contact me as soon as possible if you wish to request an excused absence.

Missing an exam for reasons such as illness, religious observance, participation in required university activities, or family or personal emergency (such as a serious automobile accident or the funeral of a close relative) all are circumstances that may qualify as an excused absence. However, you must provide documentation that the absence qualifies as excused. I will arrange a makeup exam or substitute assignment at my discretion.

The policies for excused absences do not apply to in-class activities (which cannot be made up) or project assignments. Projects will be assigned with sufficient time to be completed by students who have a reasonable understanding of the necessary material and begin promptly. In cases of extremely serious documented illness of lengthy duration or other protracted, severe emergency situations, I may consider extensions on project assignments depending upon the specific circumstances. Please contact me as early as possible if you believe you will need such an extension.

Inclement Weather

This class will operate in accord with JMU's official cancellation policy.

Catalog Description

Introduction to the theory and implementation of compilers. Explores the lexical, syntactic, and semantic analysis of high-level language code as well as code generation, optimization techniques, and architectural or operating system considerations. Course work includes a significant programming component.

Prerequisites: Prerequisites: Grades of “C-” or better in CS 327 and CS 361.

Sections: 0001
Instructor: Dr. Mike Lam
Credits: 3