San Jose State University : Site Name


Main Content

Working in Mars Mission Control, JPL

Ronald Mak

Department of Computer Engineering
Department of Computer Science
Department of Applied Data Science
Fall Semester 2020

Office hours: TuTh: 4:30-5:30 PM online via Zoom
Office location: ENG 250 (but working from home)
Mission Control, Jet Propulsion Laboratory (JPL)
NASA Mars Exploration Rover Mission

CS/SE 153 Concepts of Compiler Design

Section 1: TuTh 9:00 - 10:15 AM online via Zoom

Lab Assignments

# Date Due Assignment
1 Aug 20 Aug 27 Write Simple Pascal Programs

Assignment input file: presidents.txt
Solutions: GoSpartans.pas   ListMerge.pas   Presidents.pas

Sample Pascal program: EmployeeListing.pas
Sample program input file: employees.txt
Sample program output: employees.out.txt
2 Aug 27 Sep 3 Pascal Scanner

Simple Pascal (Java version):
Test input files: Newton.txt    ScannerTest.txt
Sample output: ScannerTest.out.txt
Sample solution:
3 Sep 3 Sep 17 Simple Pascal interpreter

Test input files and expected output: TestWhile.txt    TestWhile.out.txt    TestIf.txt    TestIf.out.txt    TestFor.txt    TestFor.out.txt    TestCase.txt    TestCase.out.txt
Sample solution:
4 Sep 17 Sep 28 Pcl interpreter using ANTLR

Executor skeleton:


Week Date Content
1 Aug 20 Zoom recording Password: p?AU7Dhs
Slides: Goals; course learning outcomes; project teams; grading; postmortem assessment report; overview of the compilation process; compiler as translator; other forms of translation; Pascal tutorials
2 Aug 25 Zoom recording Password: 1iLG==x5
Slides: It's all about translation; conceptual design; major parts of compilers, converters, and interpreters; compilers vs. interpreters; three Java packages; syntax diagrams; how to scan for tokens; basic scanning algorithm; test the scanner; current character vs. next character; consume characters and tokens

Sample code:
Aug 27 Zoom recording Password: 1&b@.YPc
Slides: Assignment #2; Pascal statement syntax diagrams; expressions; operator precedence; control statements; REPEAT statement syntax; parse tree design and operations; building a parse tree; test the parser; parse tree nodes; symbol table concepts and operations; who needs a symbol table?
3 Sep 1 Zoom recording Password: S7B3N*.6
Slides: Building the parse tree with parser methods; the symbol table and its entries; a hack; a simple interpreter
Sep 3 Zoom recording Password: 98Y%X#=j
Slides: Simple interpreter; "run time"; using the parse tree and symbol table at run time; another hack; visiting parse nodes during run time; REPEAT statement; Assignment #3; WHILE statement; IF statement and the dangling ELSE; FOR statement; CASE statement
4 Sep 8 Zoom recording Password: R71LS3E^
Slides: Assignment #3; the dangling ELSE; maximum munch; an executor improvement; syntax and semantics; options for error recovery; top-down recursive descent parsing; accomplishments so far; temporary hacks; a DFA scanner

DFA scanner:    SimpleDFAInput.txt
Sep 10 Zoom recording Password: yv!.AB43
Slides: BNF; grammars and languages; derivations and productions; EBNF; compiler-compilers; ANTLR 4; ANTLR lexer; ANTLR grammar file; Java main programs; on the command line

ANTLR example: Expr.g4    input.txt
5 Sep 15 Zoom recording Password: y$4R*2Kp
Slides: What does ANTLR do for us?; ANTLR workflow; ANTLR parse trees; syntax error handling; resolving ambiguities; visitor interface; interface ExprVisitor; base visitor class ExprBaseVisitor; labeled production rules; interface ExprLabeledVisitor; base class ExprLabeledBaseVisitor; class Executor; main

ANTLR example:
Sep 17 Zoom recording Password: 3D%m#NnE
Slides: Pcl4 grammar; package structure; Pcl4 visitor interface; Pcl4 base visitor class; class Executor; Assignment #4; declarations; constant definitions; simple type definitions; array type definitions; record type definitions; variable declarations; declarations and the symbol table; scope and the symbol table stack
6 Sep 22 Slides: Scope and the symbol table stack; nested scopes; scope of record fields; class Symtab; class SymtabStack; class SymtabEntry; Pascal declarations; grammar file Pcl5.g4; declarations and the symbol table; type specification attributes; class Typespec

ANTLR example:

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)


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

Recommended book

Writing Compilers and Interpreters, 3rd edition
Ronald Mak
Wiley Publishing, Inc., 2009
ISBN: 978-0-470-17707-5
Source files

Online Pascal tutorials

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.