| 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 |
|
| 5 | Sept 15 |
Slides:
Pascal program; declarations; data types; class Typespec; predefined types; grammar file Pcl_P1.g4; class Semantics_P1; constant definitions; variable declarations; class Converter_P1; conversion to Java
Example ANTLR 4 code: Pcl_P1.g4 Pcl_P1.zip |
| Sept 17 |
Slides:
Define new types; Pascal type definition grammar; named vs. unnamed types; convert enumerated types; type info in the symbol table; convert subrange types; convert array types;
string types; multidimensional arrays
Example ANTLR 4 code: Pcl_P2.g4 Pcl_P2.zip |
|
| 6 | Sept 22 |
Slides:
Type checking Pascal REPEAT statements and expressions; converting REPEAT statements and expressions to Java
Example ANTLR 4 code: Pcl_P5.g4 Pcl_P5c.zip |
| Sept 24 |
Slides:
Pascal record types; functions and procedures; type checking calls; scope and the symbol table stack
Example ANTLR 4 code: Pcl_P6.g4 Pcl_P6c.zip |
|
| 7 | Sept 29 | Slides: VAR parameters; WITH statement; Pascal vs. Java variable declarations; interpreter's runtime memory management; runtime stack; stack frames; runtime display; recursive calls; nested procedures and functions; allocating a stack frame; runtime error checking |
| Oct 1 |
Slides:
The interpreter back end; memory map; cell; stack frame; runtime stack; runtime display; executing statements; procedure and function calls
Example ANTLR 4 code: Pcl_X1.g4 Pcl_X1.zip Example Pascal programs: Hilbert.pas Hilbert1000.pas |
|
| 8 | Oct 6 |
Slides:
Interactive symbolic debugger; debugger features; command language grammar; read-eval-print loop (REPL); ANTLR 4 listener interface; override enter and exit methods; hooking the executor to the debugger
Example ANTLR 4 code: Pcl_X2.g4 Commander.g4 Pcl_X2.zip |
| Oct 8 | Midterm | |
| 9 | Oct 13 |
Slides:
Compiler; target machine; Jasmin assembly language; Java Virtual Machine (JVM) architecture; stack frame; runtime stack; JVM instructions; shortcut instructions; Jasmin assembler; two-level memory hierarchy; program vs. local variables; slot numbers; final compiler project requirements
Example Jasmin code: hello.j SquareRootTable.j |
| Oct 15 |
Slides:
Code templates; compilation strategy; Jasmin datatype descriptors; Jasmin assembly code generation; program fields; main method; loading and storing a program variable; procedures and functions; local variables; expressions; compare integer values; compare other datatypes; assignment statements; Jasper disassembler
Example code: CodeTest.pas CodeTest.java |
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.
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 |
|
The Definitive ANTLR 4 Reference, 2nd edition Terence Parr Pragmatic Bookshelf, 2012 ISBN: 978-1934356999 http://www.antlr.org/ |
| 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. |
| http://rextester.com/l/pascal_online_compiler |
| https://www.tutorialspoint.com/compile_pascal_online.php |
| https://www.jdoodle.com/execute-pascal-online |
| Install the ANTLR 4 plug-in for Eclipse, etc. |
| The Java Virtual Machine Instruction Set |
This is a challenging course that will demand much of your time and effort throughout the semester.