Due June 12, 1998

Your job is to write a type checker for a subset of Java. I will hand out two papers about type systems: the first is introductory, and the second one describes the system that you need to implement.

You will need to know the full abstract syntax of Java:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ast.ss
;;
;; Java abstract syntax trees
;;
;; These trees are constructed by the Java parser.
;;
;; Author:  Dan DuVarney   (dcduvarn@eos.ncsu.edu)
;; Date:    November 10, 1996
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define-record ast-literal (type value))
(define-record ast-formal-arg (type id ndims))
(define-record ast-comp-unit (package imports types))
(define-record ast-package (name))
(define-record ast-name (ids))
(define-record ast-import (name wild?))
(define-record ast-class-decl (modifiers name super implements body))
(define-record ast-var-declarator (id ndims init))
(define-record ast-method-decl (modifiers type id formal-args throws body))
(define-record ast-throws (names))
(define-record ast-binary-op (op lhs rhs))
(define-record ast-unary-op (op expr))
(define-record ast-if-then-else (condition true-stmt false-stmt))
(define-record ast-cast-op (type ndims expr))
(define-record ast-new-object-op (class-name args))
(define-record ast-new-array-op (base-type dimensions))
(define-record ast-field-lookup-op (object field))
(define-record ast-invoke-op (base id args))
(define-record ast-ctor-invoke-op (base args))
(define-record ast-array-fetch-op (array index-exp))
(define-record ast-array-type (base-type ndims))
(define-record ast-field-decl (modifiers type declarators))
(define-record ast-static-init (block))
(define-record ast-constructor-decl (modifiers id formal-args throws ctor-call body))
(define-record ast-interface-decl (modifiers name supers body))
(define-record ast-var-decl (type declarators))
(define-record ast-labeled-statement (label statement))
(define-record ast-switch (test branches))
(define-record ast-case (labels statement))
(define-record ast-break (identifier))
(define-record ast-continue (identifier))
(define-record ast-return (expr))
(define-record ast-throw (expr))
(define-record ast-synchronized (expr block))
(define-record ast-try (block handlers final-block))
(define-record ast-catch (exception block))
(define-record ast-for (initialize condition step body))
(define-record ast-while (condition body))
(define-record ast-do-while (condition body))
(define-record ast-block (statements))
(define-record ast-cond-expr (condition true-exp false-exp))
(define-record ast-null-statement ())
(define-record ast-primitive-type (name))
(define-record ast-void-expr ())
(define-record ast-default ())
(define-record ast-array-init (exprs))

Page visited times since May 19, 1998.

sabry@cs.uoregon.edu