Last update: Apr 15, 2021
- (for Thu Jan 21) PLPJ Skim Chapter 1 - Introduction (pp 1 - 25).
- (for Tue Jan 26)
PLPJ Skim PLPJ Chapter 3 (pp 55 – 70). Study PLPJ Chapter 4 Secns 4.1, 4.2 (pp 73 – 83).
- (for Thu Jan 28, Tue Feb 2)
- Parsing, Secn 4.3 (pp 83 - 84)
- Top-down parsing, Secn 4.3.2, (pp 87 - 89)
- Recursive descent parsing, Secn 4.3.3 (pp 89 - 93)
- Systematic development of recursive-descent parsers, Secn 4.3.4 (pp 93 - 109)
- (for Thu Feb 4) PLPJ Scanner construction, Secn 4.5 (pp 118 - 124)
- (for Tue Feb 9) PLPJ Abstract Syntax Trees, Secn 4.4 (pp 109 - 118)
- (for Thu Feb 18) PLPJ AST construction in Triangle (pp 124 - 128)
- (for Thu Mar 4) PLPJ Contextual Analysis - Identification (pp 136 - 149)
- (for Tue Mar 9) PLPJ Contextual Analysis - secn 5.2 Type checking (pp 151-153)
- (for Tue Mar 16) midterm exam
- (for Thu Mar 18) PLPJ Contextual Analysis implementation using the visitor pattern (pp 154 - 163)
- (for Tue Mar 30) PLPJ Runtime organization
(skim pp 173-229, read secn 7.6 pp 230 - 236 secn 6.7 on OO language runtime organization)
- (for Tue/Thu Apr 6,8)
PLPJ Code Generation Chap 7 - skim through the chapter for aspects of Triangle/TAM that apply to miniJava/mJAM
Here are small examples implementing scanning, parsing, and AST construction for simple arithmetic expressions
that correspond roughly to checkpoints PA1 and PA2 in our miniJava project.
- Download the zip file
- in Eclipse: File / Import Existing Projects into Workspace / Next
- 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
The top-level package is miniArith. It contains 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.
- AST construction: download
- Illustrates construction of an AST using the node definitions in the miniArith.AbstractSyntaxTrees subpackage.
The first traversal displays the input arithmetic expression in fully parenthesized form, reflecting precedence and
associativity rules. The second traversal evaluates the expression and displays the result. The two traversals are implemented
using a single implementation of the Visitor design pattern.
- PA4-example - Code Generation and Execution using mJAM :
and import into Eclipse as a new project.
- Generates a sequence of mJAM instructions that might be emitted by your code generation visitor applied to the example miniJava "Counter" class.
First it generates a preamble in the code store starting at location 0 that calls public static main(String  args) in class Counter with
an empty array of String, and emits the body of the main class that creates counter, an instance of the Counter class,
and applies the increase method of the Counter class, and finally prints the value of Counter.count
The generated code is then executed using mJAM in debug mode, so you can single step through the execution.
This upper-level undergraduate class (also available for graduate credit) extends and
integrates material from prerequisite courses to build a compiler for a non-trivial subset of the Java
programming language. Java is also the implementation language for the compiler.
Upon completion of this course, you should:
- Understand the theory and practice of compilers, linkers, debuggers, and program execution by
hardware or abstract machines.
- Appreciate the effect of trade-offs in programming language design and computer architecture
on program compilation and the run-time support system.
- Have gained additional experience with the design and implementation of a large and complex
program using Java.
- Be prepared for advanced study in programming languages and optimizing compilers.
Administrative details, such as prerequisites, exam dates, honor code,
and the sequence of topics covered in the course can be found in the
Programming Language Processors in Java: Compilers and Interpreters,
by David Watt and Deryck Brown, Prentice Hall, 2000 (ISBN 0-130-25786-9).
Watt & Brown, Programming Language Processors in Java
This page is maintained by
Send mail if you find problems.