Last update: Thu Mar 7 2019 by

COMP 520 - Compilers

Spring 2019 (Thu Jan 10 - Thu Apr 25)
TTh 12:30 - 1:45 PM FB 009

Instructor: Jan Prins
FB 334
Office Hours: Mon 2 - 3:30 pm

TA: Qian Zhang
Office Hours: Wed 2 - 3 pm in FB331


This is an upper-level undergraduate course (also open to graduate students) covering several areas of program translation and execution, including compilation, interpretation, optimization, and run-time organization. Upon completion of the course, you should:


Data Structures (COMP 410), Computer Organization (COMP 411), Automata Theory (COMP 455), and experience with Java programming. A course in programming language concepts (COMP 524) is helpful but not required.


Programming Language Processors in Java: Compilers and Interpreters, by David Watt and Deryck Brown, Prentice Hall, 2000 (ISBN 0-130-25786-9).

Course Syllabus

Administrative details, such as the exam dates, the honor code, and the sequence of topics covered in the course can be found in the course syllabus

@ Announcements

@ Reading Assignments

@ Lecture Notes

@ Written Assignments

@ Programming Assignments

@ Examples

Here are two examples implementing scanning/parsing and AST construction that correspond roughly to checkpoints PA1 and PA2 in our miniJava project. To install:
  1. Download the zip file
  2. in Eclipse: File / Import Existing Projects into Workspace / Next
  3. choose "Select Archive File" radio button, browse to zip file and Open / Finish
Scanner and Parser: download
Illustrates the package structure and classes for a scanner and parser (mostly following the text), and implements a scanner and parser that recognize (valid/invalid) simple arithmetic expressions using numbers, operators (+,-), and balanced parenthesization.

The top -level pacakage is miniArith contaning the Recognizer mainclass that parses input entered from the keyboard and judges whether it consitutes a valid arithmetic expression. The parse procedures corresponding to nonterminals in the grammar are traced to illustrate how the input was parsed.

The subpackage miniArith.SyntacticAnalyzer contains the Scanner, Parser, Token classes and the TokenKind enumeration.

You can use this example as a starting point for your miniJava compiler, if you wish.

AST construction and AST traversal: download
Illustrates AST construction and traversal example using a stratified grammar to parse a simple arithmetic expression entered from the keyboard. It constructs an AST that reflects the associativity and precedence of addition and multiplication operations, and respects parenthesization.

The scanner and parser are in the SyntacticAnalysis subpackage and use AST classes provided in the AbstractSyntaxTrees subpackage to construct the AST during parsing.

Two traversals of the AST are implemented as visitors in the TraverseAST subpackage: DisplayAST constructs an explicitly parenthesized text representation of the AST and EvalAST evaluates an AST.

The top level package is miniArith with main class Evaluator. It uses the scanner and parser to parse an arithmetic expression entered as input from the keyboard and to construct an AST. The two visitors are used to display the AST in linear form and to compute its value.

@ Reference Section

MiniJava Project tester


[Course text] Watt & Brown, Programming Language Processors in Java

Java Reference

Additional references

Triangle compiler

This page is maintained by Send mail if you find problems.