Please Reload Every Time You Read This Page!

CSC 124/258: Compiler Construction, Spring 2006

Dr. Chuck C. Liang
Associate Professor of Computer Science, Hofstra University .

Office Address:
201A Adams Hall
Hofstra University
Hempstead, NY 11550
Office Phone: (516 463) 5559

Email: cscccl@hofstra.edu (<- click to send me mail)

Official Office Hours: MW 5:30-6:30pm, F 1-2pm or by appointment.


Course Syllabus

Online Resources:


The following are the components of my "jBASIC" sample interpreter. Although it is an interpreter as oppposed to a compiler, it contains many of the same basic components as a compiler.

  1. jbl.lex. The lexical scanner specification to be processed by JLex.
  2. jbp.cup. The LALR grammar specification to be processed by Java_Cup. The "semantic actions" of this file builds an abstract syntax tree representation, the classes of which are defined in the next file:
  3. jbclasses.java. This file contains classes for building abstract syntax trees for jBasic, as well as code that will execute a jBasic program given its abstract syntax representation.
  4. jbinterp.java. This is the top level file that combines the lexer/parser with the interpreter defined in the above file.
  5. factorial.jb. Here is a sample jBasic program that computes 5!.
  6. README. Instructions on how to put everything together and run the interpreter.

Sample JLex Specification and usage. Additional JLex example from the JLex homepage.
Paper on elimination of left recursion. Required reading for graduate students.

Online Calculator Example:

  1. Java_cup grammar specification (unambiguous version).
  2. Ambiguous version of grammar with precedence and associativity declarations.
  3. Ambiguous grammar version that generates a tree. Tree abstract syntax.
  4. JLex scanner specification
  5. Front interface (includes compilation instructions).
  6. Version using the parameterized Visitor pattern
  7. Version with summation series and runtime stack. Also requires updated cup file.
  8. Version that generates x86 assembly. Sample code generated for [sum(i=1,3) [sum(j=1,4) i*2]]

Sample hand-coded x86 assembly for gcd and fibonacci functions. Use gcc as assembler.


Assignment 1. Due 2/9.
Assignment 2: Lexical Analyzer. Due 2/16. Support files: sym.java, mjlexertest.java
THE TRUTH LAB. Due Thursday 3/16 (firm). with truth.lex.

Compiler stage 2 : part 2A, with parsertest.java (due Tuesday 3/21).
parts 2B and 2C. (due Thursday 3/23)
Visitor Pattern warmup assignment.
part 2D: MiniJava to C++ translator. With front end transcpp.java and cpputils.cpp.
Sample translations: MJtest.mj and MJtest.cpp; with extensions: MJplustest.mj and MJplustest.cpp
Compiler stage 3: Symbol tables and type checking.

Assembly language warmup assignment
sample program from 4/18 class.

Compiler Stage 4a: Beginning Code Generation
with abstract assembly structures and front-end.
Completing the Code Generator

Sample Minijava programs to test: simple.mj (main only), MJ4b.mj.
Sample generated code (after peephole optimization): simple.s, MJ4b.s

Clarifications on how to use immediate operands and memlabel class
Miscellaneous notes about division and other issues
Some peephole optimization routines

More test cases for you to compile: fact.mj (must deal with this.f(...)). bbs.mj (bubblesort, arrays). teams.mj (objects as parameters).


Announcements:

Final test cases: nestedifs.mj, funobj.mj, and newobj.mj

We will meet Thursday at the regular class time for the final demonstrations. I will prepare a number of test cases for you, some of which I will give you at the final demonstration. Attendance Thursday is absolutely required. You must demonstrate and submit your complete compiler.

In order to get the highest possible scores, you should also complete the type checker. Here's an additional hint on how to do that.

Please see more notes and other miscellaneous comments above.

Read chapters 4,5,6 of the text.