San Jose State University : Site Name

Navigation

Main Content

Working in Mars Mission Control, JPL

Ronald Mak

Department of Computer Science
Fall Semester 2014

Office hours: MW: 6:00-7:00 PM
Office location: MacQuarrie Hall, room 413
E-mail: ron.mak@sjsu.edu
Mission Control, Jet Propulsion Laboratory (JPL)
NASA Mars Exploration Rover Mission

[HOME]

CS 153/SE 153: Concepts of Compiler Design


MW 9:00-10:15 AM, SCI 311



Assignments


# Date Due Assignment
1 Aug 25 Sept 5 Write a Pascal program
Input file: employees.txt
2 Sept 8 Sept 17 Java scanner
Input file: javatest.in
3 Sept 17 Oct 1 Pascal set expressions and assignments
Input files: sets.txt    seterrors.txt


Lectures


Date Content
Aug 25 Slides: Goals; compiler as translator; definitions; overview; conceptual designs; parser; scanner; token; front end; intermediate tier; backend; intermediate code; symbol table; code generator; compiler project; grading
Aug 27 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;

Sample Pascal programs:
newton.pas   newton.j (Jasmin assembly language object program)
wolfisland.pas   wolfisland.in (Wolf Island input data)
Sept 3 Slides: Initial Pascal-specific parser and scanner; token class; factory classes; initial back end classes; first end-to-end test Pascal tokens; Pascal token classes; syntax diagrams; how to scan for tokens; basic scanning algorithm
Sept 8 Slides: Pascal scanner and token classes: word, string, and 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
Sept 10 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; Pascal precedence rules; example expression decomposition; parsing expressions
Sept 15 Slides: Parsing expressions; printing parse trees; temporary hacks; statement and expression executor classes; executing compound statements, assignment statements, and expressions; runtime error handling; Simple Interpreter I; Pascal control statements; statement parser classes; parsing REPEAT and WHILE statements; synchronization and error recovery; Pascal Syntax Checker II
Sept 17 Slides: Assignment #3; parsing FOR, IF, and CASE statements; top-down recursive descent parsing; syntax and semantics; executing REPEAT, WHILE, FOR, and IF statements


Goals


First goal: You'll learn the concepts of writing compilers and interpreters for high-level programming languages. You'll write your compilers and interpreters in Java.

In the first half of the course, you'll learn about the front end of a compiler or interpreter: the scanner and the parser; and its middle tier: symbol tables and intermediate code (parse trees). You'll also learn how an interpreter executes source programs in its back end. You'll understand and modify the Java code of a working interpreter. The interpreter will execute source programs written in the Pascal programming language.

In the second half of the course, you'll write your own compiler using JavaCC, the Java compiler-compiler. Your compiler will translate programs written in the high-level language of your choice — or perhaps in a language that you invent — first to Jasmin assembly language and then to .class files that will execute directly on the Java Virtual Machine (JVM).

Compilers and interpreters are complex programs, and writing them successfully is hard work. To tackle the complexity, we'll take a strong software engineering approach in this course. We'll use design patterns, Unified Modeling Language (UML) diagrams, XML, and other modern object-oriented design practices to make the code understandable and manageable.

Second goal: You'll learn critical job skills that employers look for in new college hires:


Prerequisites


CS 47 or
CMPE 102
Introduction to Computer Organization
Fundamentals of Embedded Software
grade C- or better
CS 146 Data Structures and Algorithms grade C- or better
CS 154 Formal Languages and Computability grade C- or better
  Department policy is to enforce  
  all course prerequisites strictly,  
  especially for a deep course.  


Required books


Writing Compilers and Interpreters, 3rd edition
Ronald Mak
Wiley Publishing, Inc., 2009
ISBN: 978-0-470-17707-5
Source files from each chapter
Generating Parsers with JavaCC, 2nd edition (PDF)
Tom Copeland
Centennial Books, 2009
http://generatingparserswithjavacc.com/
ISBN: 0-9762214-3-8


Recommended books


Programming for the Java Virtual Machine
Joshua Engel
Addison-Wesley Professional
ISBN: 0201309726
The Essentials of Pascal I
Gary W. Wester
Research and Education Association
ISBN: 0-87891-694-6
The Essentials of Pascal II
Gary W. Wester
Research and Education Association
ISBN: 0-87891-718-7


Online Pascal tutorials


Learn Pascal  Looks good, although it doesn't appear to cover set types.
Pascal Programming  Ignore Lesson 3. Also doesn't cover set types.
Pascal - Sets  A tutorial on Pascal set types.