COSC4307 Course Syllabus Fall 2009
Required Textbook:
Compilers: Principles, Techniques, and Tools, 2nd edition, by Alfred Aho, Ravi Sethi and Jeffrey Ullman,
Addison Wesley.
Other References:
1. Engineering a Compiler, by Keith D. Cooper and Linda Torczon, Morgan Kaufmann Publishing, 2004
2. Crafting a Compiler with C++, by Charles N.Fischer, et al, Benjamin/Cummings, 1996
Instructor: Dr. Hikyoo Koh, Professor of CS
Office: MA68
Phone: 880-8779
E-Mail: hkoh@my.lamar.edu (or HKPK32@Yahoo.com)
HTTP: galaxy.cs.lamar.edu/~hkoh
Office Hours:
MW: 18:50-19:30
TTh: 13:00-14:00 and 15:20-16:00
Learning Objectives:
By taking this course, students will
1. Understand basic components of a compiler.
2. Understand some design issues of compilers.
3. Understand roles of CFG and some useful binary relations.
Leftmost-Deriving, Rightmost-Deriving, and Adjacency
4. Understand functionalities of compiler components
5. Understand techniques for intermediate code generation
6. Understand common techniques for independent optimizations and
7. Implement abbreviated versions of some compiler components:
Scanner, Parser, and Intermediate Code Generator.
Topics to cover:
Introduction: Five components of a compiler
Three languages of a compiler
Notations involving program compiling/executing
Design issues: Bootstrapping, Passes, Subprograms
Recommended Object-Oriented Design:
Class: LamarCompiler
a. Methods
Scanner
Parser
QuadGen
CodeGen
b. Instance Variables
Source (Source input program)
Grammar (Input CFG Grammar)
NextMatrix
SymbolTable
TokenSequence
ParseTree
Quadruples
TargetCode
Grammars: Symbols, Production rules, Derivations,
Reductions, Ambiguity
Relations: Leftmost-Derivation
Rightmost-Derivation
Adjacent
Next-To
Scanners: Tokens, Symbol tables
Static memory allocation vs Dynamic allocation
Regular expressions, Finite-State Acceptors
Auxiliary functions:
Static Storage allocation
Symbol table maintenance
Compacting source programs
Lexical (Pre-parser) error checking
Test-1
Parsing: Top-down vs Bottom-up
Deterministic vs nondeterministic
LL(1) Parsers, Predict sets, FIRST sets, FOLLOW sets
Two obvious obstacles:
Left-recursive rules
Common prefix
Recursive descent parsers
Bottom-up parsers
Precedence relations: Operator precedence
Simple precedence
Shift-Reduce parsers based upon precedence matrix
LR(k) Parsers based upon viable prefix
Comparisons of parsers
Test-2
Intermediate code generation:
Quaruples, Triples, polish expressions.
Translation of simple language constructs.
Translation of other constructs:
Loops
Arrays
Boolean expressions, Procedure calls
Error handling:
Error detection/report
Error recovery
Error repair
Optimization: Machine-independent and Machine-dependent
Basic blocks, Local optimization, Loop optimization,
Data Flow Analysis
Code Generation:
Instruction Selection
Instruction Scheduling
Register Allocation
Grading method:
2 tests: 200 points
Final exam: 200 points
6 or more programs: 120 points
Occasional Pop Quizzes: 40 points
------------------------------------------------------
TOTAL: 560 points
Your final grade will be primarily determined by your class average as follows:
85% or above: A
Else 75% or above: B
Else 65% or above: C
Else D
Students with Disabilities:
This course complies with the University Policies on Disability,
Accommodations and Academic Honesty as published in the Student Handbook
and also in the Computer Science Department policy on Academic Honesty.
Online Course Evaluation
NOTES:
1. Every thing you turn in to the instructor to be graded is expected to be your own work at least for the
most part.
In the unpleasant event of the instructor identifying two or more students having submitted an identical or
a very similar program, all students involved will get ZERO credit for all the programming assignments
for the course.
Furthermore, when such an incident occurs twice to a student, he/she will get an F for the course.
No solution program available locally or on the Internet should be copied without the prior approval
of the instructor.
2. All programs will be accepted only in class and only when they are due. No sooner or no later.
3. It is to your advantage if you highlight all PRINT or WRITE or cout statements of your programs to
clearly indicate where in your program the outputs are being actually being done.
4. The very beginning of each program should have a comment that includes:
a. Your name, course number, program number, and program title.
b. The main objective of the program.
c. Your own self-assessment of the program. This includes
(i) whether or not your program works fully.
(ii) if not a. the extent to which the program does not work.
b. why you think it is not working.
c. whether or not it compiled at all.
Without this self-assessment, your incomplete (or otherwise not producing expected correct results)
program will not be graded and NO Credit.
5. The main function must appear at the end of the program when the language Syntax permits.