Please Reload Every Time You Read This Page!

CSC 124/258: Compiler Construction, Spring 2014

Dr. Chuck C. Liang
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: Monday-Thursday 3:30-4:30pm

The homepage of the previous time that I taught this course is available here


Course Syllabus

Online Resources:


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

  1. jbl.flex. The lexical scanner specification to be processed by JFLex, for use with my own parser generator. Here's the one to use with Java Cup.
  2. jb.grammar. The grammar specification used by my own LR(1) parser generator. Here is the same grammar in Java Cup syntax (version .10k). The "semantic actions" of this file builds an abstract syntax tree, 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. jbrun.java. This is the top level file that combines the lexer/parser with the interpreter defined in the above file. If you wish to run it before having completed your own parser generator, you should use the version for java cup.
  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 (using Java cup).

Lambdascript example: programming with pure lambda terms using Krivine's abstract machine:
java implementation, LR(1) grammar and sample program.

Some sample grammars (in my syntax):

  1. simple LR(0) grammar
  2. slightly more interesting LR(0) grammar
  3. Ambiguous grammar with reduce-reduce conflict,
  4. Grammar for testing Nullible, First and Follow set computations
  5. Ambiguous grammar for online calculator. Must read the attached comments.
  6. Unambiguous SLR(1) grammar for online calculator. Here is the generated parser
  7. LALR(1) but not SLR(1) grammar from the Dragon book
  8. LR(1) but not LALR(1) grammar from the Dragon book
  9. Hacked parser to recognize non-context free language using semantic checks. Read the comments.
  10. Java 1.4 grammar (converted from .cup version). This is the torture test of your parser generator.

Sample hand-coded x86 assembly language programs in gnu syntax:
fibonacci sequence, summing an array


The Truth Lab. (progressive assignment - reload for latest).
Some guidelines, code fragments, are found here.
Parser Generator Stage 1. The content of this assignment will be the subject of your next progress grade. I've added my version of the function to compute the Nuillible set. Reload for latest
Parser Generator Stage 2: Generating the State Machine.
Parser Generator Stage 3: Generating the Parser.
Parser Generator Final.


Visitor Pattern Warmup Assignment (Optional).

MiniJava+ compiler project overview
Lexer and Parser (RELOAD FOR LATEST). Due Tuesday 4/1
Abstract Syntax and Visitor Pattern (now with Translator). Due Thursday 4/10
Symbol Table and Type Checker. Due Thursday 4/17
Additional guidelines for type checking
x86 assembly language assignment

Projected:
Translation to an intermediate langauge (abstract assembly). Due 4/24
Some Optimizations and Static analysis. Due 5/1.
Learning x86 assembly language, understanding calling conventions. 5/8
Translation to x86 assembly, final exam, 5/15


Announcements:

Minijava+ program to test type checking

More sample Minijava+ program to test your parser and translator on: test.mj, fact.mj, Quicksort.mj

Program to test your assembler: power2.c. Follow instructions in comments.

test cases for parser generator: nonllk.grammar, nonllk.flex
srr.grammar
fact2.jb
Check List

Nasty grammars for testing stage 2: nasty1, nasty2, nasty3

Read Chapter 2,3,4,5 of textbook.