San Jose State University : Site Name

Navigation

Main Content

Working in Mars Mission Control, JPL

Ronald Mak

Department of Computer Engineering
Fall Semester 2018

Office hours: TuTh: 3:00-4:00 PM
Office location: ENG 250
E-mail: ron.mak@sjsu.edu
Mission Control, Jet Propulsion Laboratory (JPL)
NASA Mars Exploration Rover Mission

CMPE 152: Compiler Design


Section 1 (class):  TuTh  4:30 - 5:20 PM  room ENG 343
Section 2 (lab):  Tu 6:00 - 8:45 PM  room ENG 206
Section 3 (lab):  Th 6:00 - 8:45 PM  room ENG 206


Assignments

# Date Due Assignment
1 Aug 21 Aug 29 Write Pascal Programs

Sample Pascal program: EmployeeListing.pas
Input file: employees.txt
Output: output.txt

Sample solution #1: HelloWorld.pas
Sample solution #2: SortArray.pas    SortArray.out.txt
Sample solution #3: Presidents.pas    Presidents.out.txt
2 Aug 30 Sep 12 C++ Scanner

Input: cpptest.in
3 Sep 11 Sep 28 WHEN statement

Input: when.txt    whenerrors.txt
4 Sep 27 Oct 8 New complex type

Input: ComplexAssignments.txt

Lectures

Week Date Content
1 Aug 21 Slides: Goals; course learning outcomes; project teams; grading; postmortem assessment report; overview of the compilation process; compiler as translator; Assignment #1
Aug 23 Slides: Interpreters; compiler vs. interpreter; key steps for success; Java packages; class relationships; abstract parser and scanner classes; token and source classes; currentChar() vs. nextChar(); messages;
Lab Slides: Pascal programming workshop
2 Aug 28 Slides: Initial Pascal-specific parser and scanner; token class; factory classes; initial back end classes; first end-to-end test; Pascal token classes
Aug 30 Slides: Basic scanning algorithm; Pascal scanner; Pascal token classes: word, string, number; syntax error handling; Pascal tokenizer; Assignment #2; symbol table conceptual design; symbol table interfaces; symbol table factory class; symbol table and symbol table stack implementation
Lab Slides: Install development environment; compile and run Chapter2cpp sources
3 Sep 4 Slides: Symbol table entries; what to store in each entry; cross-reference listing; statement syntax diagrams; parse tree conceptual design; syntax diagrams: Pascal statements and expressions; parse tree: conceptual design, basic operations, implementation, building
Sep 6 Slides: Pascal expression syntax; precedence rules; example expression decomposition; parsing expressions; Parsing expressions; printing parse trees; Pascal Syntax Checker I; temporary hacks; statement and expression executor classes; executing compound statements, assignment statements, and expressions; runtime error handling; Simple Interpreter I
Lab Slides: Work on Assignment #2
4 Sep 11 Slides: Parsing REPEAT and WHILE statements; error synchronization and recovery; Pascal Syntax Checker II; parsing FOR and IF statements; Assignment #3
Sep 13 Slides: Parsing CASE statements; top-down recursive descent parsing; syntax and semantics; control statement executors; executing loops; executing if and CASE statements

An article about the FORTRAN compiler for the IBM 1401 computer system. The compiler made 63 passes and ran in 8K of memory; each pass had at most 300 instructions! Assembly language source code of the compiler. Just read the comments for enlightenment.
Lab Slides: Work on Assignment #3
5 Sep 18 Slides: Multipass compilers; parsing declarations; syntax diagrams for Pascal declarations; constant definitions; type definitions: simple, array, and record; variable declarations; declarations and the symbol table; scope and the symbol table stack;
Sep 20 Slides: type specification interfaces and attributes; string types; type factory; how identifiers are defined; predefined identifiers and types; BlockParser; DeclarationsParser; ConstantDefinitionsParser
Lab Slides: Work on Assignment #3
6 Sep 25 Slides: Type definition structures; TypeDefinitionsParser; TypeSpecificationParser; SimpleTypeParser; SubrangeTypeParser; EnumerationTypeParser; RecordTypeParser; Pascal multidimensional arrays
Sep 27 Slides: Parsing variables with subscripts and fields; type checking; adding type information to parse tree nodes; assignment and comparison compatible; type checking expressions and control statements; parsing variables; Assignment #4
Lab Slides: Finish Assignment #3
7 Oct 2 Slides: Program header; procedure and function declarations; forward declarations; nested scopes and the symbol stack; parsing programs, procedures, and functions; parsing calls to procedures and functions; class Predefined; formal and actual parameters; parsing calls to the standard routines
Oct 4 Slides: The interpreter; compile time vs. run time; runtime memory management; symbol table stack vs. runtime stack; activation records; access to nonlocal variables; recursive calls; allocating and initializing activation records; passing parameters during a call; memory management classes
Lab Slides: Assignment #4
8 Oct 9 Slides: Procedure and function call classes; runtime error checking; execute entire Pascal programs; review for the midterm

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.

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 books

Writing Compilers and Interpreters, 3rd edition
Ronald Mak
Wiley Publishing, Inc., 2009
ISBN: 978-0-470-17707-5
Source files
The Definitive ANTLR 4 Reference, 2nd edition
Terence Parr
Pragmatic Bookshelf, 2012
ISBN: 978-1934356999
http://www.antlr.org/

ANTLR 4 C++ .h files and runtime libraries for Windows 10:
antlr4-cpp-runtime-4.7-Windows10.zip

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

http://rextester.com/l/pascal_online_compiler
https://www.tutorialspoint.com/compile_pascal_online.php
https://www.jdoodle.com/execute-pascal-online