San Jose State University : Site Name

Navigation

Main Content

Goals of the course, JPL

Ronald Mak

Department of Computer Science
Department of Applied Data Science
Engineering Extended Studies
Fall Semester 2026

Office hours: Tuesdays and Thursdays 3:00 - 3:30
Office location: Duncan Hall DH 209
E-mail: ron.mak@sjsu.edu
 
Click for:
Open student internships
at the NASA Ames Research Center

Check regularly. Positions open sporadically.

CS/SE 153 Concepts of Compiler Design


Section 1: TuTh 1:30 - 2:45 PM room MH 422


Assignments

# Date Due Assignment
Aug 20 Aug 24 Submit proof of prerequisites to Canvas:
Assignments/Miscellaneous/Course prerequisites
Aug 20 Aug 26 Submit project team info (one submission per team) to Canvas:
Assignments/Miscellaneous/Project team info
1 Aug 27 Sept 3 Simple Scanner and Parser

Simple: Simple.zip
Test input files: TestWhile1.txt    TestWhile2.txt    TestIf1.txt    TestIf2.txt    TestIf13txt    TestIf4.txt    TestFor1.txt    TestFor2.txt    TestFor3.txt    TestCase1.txt    TestCase2.txt
Sample solution: Asgn1Solution.zip
2 Sep 3 Sep 10 Simple Interpreter

Test input files: TestWhile.txt    TestIf.txt    TestFor.txt    TestCase.txt   
Expected output: TestWhile.out.txt    TestIf.out.txt    TestFor.out.txt    TestCase.out.txt
Sample solution: Asgn2Solution.zip
3 Sep 10 Sep 17 Simple Interpreter using ANTLR 4

Test input files: TestWhile.txt    TestIf.txt    TestFor.txt    TestCase.txt   
Expected output: TestWhile.out.txt    TestIf.out.txt    TestFor.out.txt    TestCase.out.txt

Lectures

Week Date Content
1 Aug 22 Slides: Goals; course learning outcomes; project teams; grading; postmortem assessment report; types of programming languages; it's all about translation; language classes during translation; Pascal; example translations: conversion, execution, debugging, compilation

Example Pascal program: SquareRootTable.pas
Example language conversion (Pascal to Java): SquareRootTable.java
Example object code (Jasmin): SquareRootTable.j
2 Aug 25 Slides: A software architecture; parser; tokens; scanner; parse tree; symbol table; backend components; translator control flow; translator data flow; Pascal tokens; syntax diagrams; how to scan for tokens; basic scanning algorithm; test the scanner; current character vs. next character; consume characters and tokens

Simple scanner, parser, and interpreter: Simple.zip
Aug 27 Slides: Statement and expression syntax diagrams; operator precedence; Pascal control statements; parse tree conceptual design; parse tree operations; building a parse tree; classes: Scanner, Token, Node, SymtabEntry, Symtab; symbol table hack #1; syntax error handling; Parser methods; statements: WHILE, IF, FOR, CASE; dangling ELSE
3 Sept 1 Slides: Symbol table: concept, design, operation, hacks; parse program, assignment statement, variable; listing; cross-reference table; Simple interpreter; visiting tree nodes; runtime uses of parse tree and symbol table; visit tree nodes: program, compound statement, assignment statement, REPEAT statement, IF statement, expressions
Sept 3 Slides: Top-down recursive descent parsing; Chomsky language hierarchy; DFA scanner; syntax and semantics; grammars and languages; derivations and productions; ANTLR 4; translation workflow; multiple passes

Example code: SimpleDFAScanner.zip
4 Sept 8 Slides: ANTLR 4 grammar file; metasymbols; token definitions; production rules; generated parser; testing tool; context classes; visit methods; base visit method implementations; create the symbol table; overriding base methods; syntax and semantic error handlers; order in the grammar file

Example ANTLR 4 grammar file: SimpleA1.g4
Example ANTLR 4 code: SimpleA1.zip
Sept 10 Slides: ANTLR 4 generated Context classes and visit methods; custom tree node fields; new semantic visit method overrides; pass 3 tree walk; executor visit method overrides; labeled rule alternatives

Example ANTLR 4 code: SimpleA2.g4   SimpleA2.zip   SimpleA3.g4   SimpleA3.zip

First draft: Build a Programming Language (From Scratch)

Chapter Title Files
1 Building a programming language
2 Specifying a programming language's grammar
3 A software architecture for translators
4 Installing and testing ANTLR 4 Simple.g4   example.simp   example2.simp

Goals of the course

This course will concentrate on practical aspects of compiler construction, programming language design, and engineering a large, complex software application.

This is a challenging course that will demand much of your time and effort throughout the semester.

Course Learning Outcomes (CLO)

Prerequisites

Department policy is to enforce
all course prerequisites strictly

CS 47 Introduction to Computer Systems
or CMPE 102 Assembly Language Programming
grade C- or better
CS 146 Data Structures and Algorithms grade C- or better
CS 154 Formal Languages and Computability grade C- or better

Required book

The Definitive ANTLR 4 Reference, 2nd edition
Terence Parr
Pragmatic Bookshelf, 2012
ISBN: 978-1934356999
http://www.antlr.org/

Online Pascal tutorials

We will use Pascal as the example source language.
Pascal Tutorial  looks very good. It has an online Pascal compiler.
Learn Pascal  also looks good, although it doesn't appear to cover set types.

Online Pascal development sites

You can edit, compile, and run Pascal programs online.
http://rextester.com/l/pascal_online_compiler
https://www.tutorialspoint.com/compile_pascal_online.php
https://www.jdoodle.com/execute-pascal-online

Other useful tutorials.

Install the ANTLR 4 plug-in for Eclipse, etc.
The Java Virtual Machine Instruction Set

Software to Install

You should install and use an interactive development environment (IDE) such as Eclipse or IntelliJ. To develop translators for your language, you will need to download and install the ANTLR 4 package and its Eclipse or IntelliJ plugin, and then modify them to generate the necessary compiler components in Java. Instructions for ANTLR 4 will be provided when the time comes.

Project teams

You will form small project teams. Team membership is mandatory for this class. The teams will last throughout the semester. Once the teams are formed, you will not be allowed to move from one team to another, so form your teams wisely!

Course Requirements and Assignments

You must have good Java programming skills and be familiar with development tools such as Eclipse or IntelliJ.

Team-based lab assignments will provide practice with compiler design techniques and give you experience adding new features to a large legacy code base. Each student on a team will receive the same score for each team assignment.

Each team will submit its assignments into Canvas, where the rubric for scoring each will be displayed. Late assignments will lose 20 points and an additional 20 points for each 24 hours after the due date.

This is a challenging course that will demand much of your time and effort throughout the semester.