Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456 COMP 520: Compilers (Fall 2006)
Last update: Wed Dec 13 2006
by prins@cs.unc.edu
Secretary: Madelyn Mann
SN 353, Tel: 962-1922,
mann@cs.unc.edu
Overview
This is an upper-level undergraduate course (also open to graduate
students) covering several areas of program translation, including
compilation, interpretation, run-time organization, linking, and
loading. Upon completion of the course, you should:
Understand the theory and practice of compilers, interpreters,
assemblers, linkers, and loaders, and be able to work effectively with
such programs.
Be able to design and implement parsers and language translators
for simple languages.
Appreciate the effects of decisions in programming language and
computer architecture design on the translation process and run-time
systems.
Have experience with the design and implementation of large and complex
programs in a Java/Unix environment.
Retain knowledge of the organization of compilers and interpreters
in preparation for advanced courses in compilers and/or advanced
computer science studies.
Prerequisites
COMP 410 (Data Structures), and COMP 411 (Computer Organization), and
experience with Java programming. A course in programming language
concepts such as COMP 524 will be very helpful but is not required.
Text
Programming Language Processors in Java: Compilers and Interpreters,
by David Watt and Deryck Brown, Prentice Hall, 2000 (ISBN 0-130-25786-9).
Course overview
Administrative details, organization and a syllabus for the course
can be found in the
course information handout.
Submission deadline for PA4 grading: Saturday Dec. 2 noon.
Guest speakers in class Thu Nov. 2: Rick Langston and Quan Zhou
from the SAS Compiler group.
PA2 compiler testing is complete. Scores are in your submission
directories, and the test cases are available below.
Three sets of tests were run. Group "0.25" are tests from PA1
rerun on PA2. Group "1" are small tests for PA2.
The ASTs generated for "pass" tests were compared against the ASTs
also found here. Group "10" is a single larger PA2 test.
Reading Assignments
(for Tue Dec 5) PLPJ Review sections of Chapter 2
that we read previously and read section 2.6 on bootstrapping
a compiler.
Nov 7 - Compiler Project PA4
miniJava Code Generator
due Tuesday November 21 (or Mon November 27 after Thanksgiving).
Submission deadline for PA4 grading: Saturday Dec. 2 noon.
The mJAM package containing the mJAM machine model, instruction
format, object code file reader and writer, mJAM interpreter,
and disassembler is available as a
zip file. This package
contains a Test class that emits a set of instructions
to illustrate the layout of class objects in mJAM (these are
not needed for the current assignment).
The Test class also generates an assembly file with the code
in readable form and runs the interpreter on the object code, using
the machine state display mechanism (HALT (4)) to show the
layout of values on the stack and in the heap.
Install this package in the same directory
holding the miniJava package. Note: The Assembler
function is not yet implemented in this package, but it is not
needed for code generation or code execution.
Note on static members of classes in miniJava PA3.
You may signal an error for any declaration of a member
of a class with attribute static,
with the exception of
a main() method, and the out field in
the predefined System class.
You may signal an error for any reference to a static member
with the exception of the System.out field.
The net effect of these restrctions is intended to be that the only
qualified references that start with a class name are
System.out.print and System.out.println,
and that it is not possible to invoke a static main
method in a class from within that class or from any other class.
The AbstractSyntaxTrees package for miniJava
that includes all AST classes, the visitor Interface, and an AST
Display class is available as a
zip file.
Very simple expression parser example that
does not use a scanner and that only parses expressions over +, - and
single digit integer literals.
More complete arithmetic expression evaluator
that scans and parses arithmetic expressions, builds an AST, and
evaluates the tree. The concrete grammar enforces operator precedence.
The MIPS instruction set is summarized in section A.10 from
Appendix A
of Hennessy and Patterson,
Computer Organization and Design: The Hardware/Software Interface.
Instructions for the installation of the Triangle compiler under Unix.
Change to the directory where you want to install the compiler
Copy the compiler and interpreter sources: cp -pr /afs/unc/proj/courses/comp520-f06/tools .
This will create directories tools/Triangle (the compiler)
and tools/TAM (the Triangle Abstract Machine interpreter).
Instructions for compiling and running the Triangle compiler on
classroom.cs.unc.edu or swan.cs.unc.edu.
Change to the tools directory containing the Triangle compiler
and the interpreter.
Make sure /usr/java/bin is in your PATH.
Compile the Triangle compiler: javac Triangle/Compiler.java
(you may need to specify the command line flag -Xlint:deprecation
to ignore the outdated AST drawer that doesn't work anyways).
Compile the interpreter: javac TAM/Interpreter.java
Run the Triangle compiler on a sample input program p1.tri: java Triangle/Compiler p1.tri
Run the interpreter on the object code generated in file obj.tam: java TAM/Interpreter obj.tam
This page is maintained by
prins@cs.unc.edu.
Send mail if you find problems.