San Jose State University : Site Name

Navigation

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)
E-mail: ron.mak@sjsu.edu
Mission Control, Jet Propulsion Laboratory (JPL)
NASA Mars Exploration Rover Mission

CMPE 152: Compiler Design


Section 1: TuTh 3:00 - 4:15 PM 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 (C++ version): SimpleCpp.zip
Test input files: Newton.txt    ScannerTest.txt
Sample output: ScannerTest.out.txt
Sample solution: Asgn02Cpp.zip
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: Asgn03Cpp.zip
4 Sep 17 Sep 28 Pcl interpreter using ANTLR

Executor skeleton: Asgn04Cpp.zip

Lectures

Week Date Content
1 Aug 20 Zoom recording Password: +k93RSrV
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: .7I0K*b8
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; Object.h

Sample code: SimpleCpp.zip
Aug 27 Zoom recording Password: %2fuxA?4
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: y59k7V+R
Slides: Building the parse tree with parser member functions; the symbol table and its entries; a hack; a simple interpreter
Sep 3 Zoom recording Password: n&2?f^GS
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: 83p!hpQ1
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: SimpleDFAScanner.h    SimpleDFAScanner.cpp    SimpleDFAInput.txt
Sep 10 Zoom recording Password: LV#?8kPA
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    ExprMain.cpp    input.txt
5 Sep 15 Zoom recording Password: A3eJjWY$
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: ExprLabeledCpp.zip
Sep 17 Zoom recording Password: ?7CdFVMS
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

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.

CMPE 102 Assembly language programming grade C- or better
CMPE 126 Algorithms and data structure design 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/

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.
http://rextester.com/l/pascal_online_compiler
https://www.tutorialspoint.com/compile_pascal_online.php
https://www.jdoodle.com/execute-pascal-online