| Date | Assignment | Due |
|---|---|---|
| Aug 25 | Form project teams | Sept 3 |
| Aug 27 |
#1: Pascal Xref program (see end of Aug 27 slides) WordScanner.java Proposed solutions: xref-noptrs.pas xref-ptrs.pas Sample command: xref-noptrs < hello.pas |
Sept 5 |
| Sept 15 |
#2: Add pointer variables and GOTO and WITH statements Assignment #2 Proposed solution: Download Assignment2.zip from http://www.apropos-logic.com/wci3/ See also: Solution notes, Syntax diagrams Test files: gotos.txt gotoerrors.txt pointers.txt pointers2.txt pointererrors.txt with.txt with2.txt witherrors.txt |
Sept 24 |
| Sept 29 |
#3: Parse declarations Assignment #3 Proposed solution: Download Assignment3.zip from http://www.apropos-logic.com/wci3/ See also: Solution notes Test files: labels.txt labelerrors.txt gotos.txt gotoerrors.txt pointers.txt pointererrors.txt variants.txt varianterrors.txt withs.txt withs2.txt witherrors.txt |
Oct 20 |
| Oct 27 |
#4: Generate a Pascal scanner with JavaCC Assignment #4 Proposed solution: pascal.jj Test files: words.txt numbers.txt symbols.txt comments.txt string1.txt string2.txt scannertest.txt |
Nov 3 |
| Nov 10 |
#5 Generate a parser with JavaCC Assignment #5 |
Nov 17 |
I will teach the concepts of designing compilers and interpreters for programming languages. You will use Java to write your compilers and interpreters. The source language that you will translate initially will be a major subset of Pascal, a simple but powerful procedure-oriented language. Your compiler will generate Jasmin assembly code for the JVM, the Java Virtual Machine. (You will be provided an assembler.)
In the first part of the course, you will learn about the translator front end of compilers and interpreters: the scanner and the parser; and about their middle tier: the symbol table and the intermediate code (parse tree). I will provide Java code for you to understand, modify, integrate, and deploy into a working translator that will read a Pascal program and create the symbol table and the parse tree.
In the middle part of the course, I will again provide Java code for you to implement the back ends of a compiler and an interpreter. You will be able to run your Pascal programs, both interpreted and as executable code compiled for the JVM!
By the last part of the course, you will have a good understanding of the concepts behind compilers and interpreters. We'll then examine JavaCC, the Java Compiler-Compiler. You'll learn how to provide JavaCC with a grammar that defines a source language, and it will automatically generate the Java code that implements a scanner and a parser for that language. Your project will be to use JavaCC and create your own compiler for Pascal or another programming language that you choose — or even invent your own language.
I am currently writing the third edition of my book, Writing Compilers and Interpreters: A Software Engineering Approach. I will provide drafts of chapters from this book to serve as the main text for the course. This has both advantages and disadvantages. You will get chapters from a new book for free. You will help me clarify the text and debug its programs. Students who provide substantial useful feedback will, with their permission, be named in the book's acknowledgments. You will get an instructor who is familiar with the course text. (But be aware that the author of a book hasn't necessarily read the book!)
Being the geek that I am, I am enthusiastic about compiler writing and I hope to convey some of that enthusiasm to you. The field has a substantial body of theory and algorithms, especially in the areas of parsing and optimization. But I want you to learn by doing — by getting code to work. So at least initially, we'll employ relatively simple techniques and algorithms. You'll work together in small teams. Bring your laptops to class so we can try to have some "lab time" and share the excitement of seeing our code in action.
Compilers and interpreters are complex programs! Throughout the course, I will emphasize and insist upon good object-oriented design and software engineering practices. I hope the course will be exciting, fun, and educational.
| Past courses I've taught at SJSU |
|---|
| Spring 2008: CS 160 Software Engineering |