The Winter 1998 section of Compilers is now over. If you are finishing an Incomplete Grade in the course, read the Incomplete Grade Policy, below, to find out where and when to deliver your final assignments.
If you are considering asking for a grade of "Incomplete" in this course, read this.
I'm making my last visit to the assignment box at 6pm on Thursday, April 30. Missing assignments prevent you from passing the course.
Welcome to CST 8152, Winter 1998 section. This course is centred around electronic delivery, including Web course notes, online discussion via News Groups, and submission of assignments on diskettes as well as traditional paper. You can see the course notes and participate in the online discussions from anywhere in the world that has an Internet connection. Assignments will be announced in the news groups.
As mature C Language programmers, you will be exposed to programming constructs and functions that may not be covered directly by the course notes or lectures. Learn to use the online help files for your compiler. Check out my alternate resources section, especially the section dealing with programming at Algonquin. You can also post questions to the online course discussion group.
If you haven't spent time learning how to use a C Language debugger, start right away. You will be building a program of some 1,000-1,500 lines over the course of a few months. If you can't set breakpoints, "watch" variables, or single-step your code, you may not be able to complete the final project and finish the course.
This is the official course outline for CST 8152, Winter 1998, in Corel WordPerfect 6 (*.wpd) format.
This is the official course outline for CST 8152, Winter 1998, in PDF format.
- I have prepared some questions and notes to accompany the course text. Midterms and the final exam will be based on questions from this list. This list is updated weekly to correspond to material covered in the lectures.
- Here's how many of the jargon words relate to each other. This is what the course is all about.
- Read Improving and Fixing C Code to learn how to avoid common errors in this course.
- C programmers have conventions about different ways of writing the constant "zero" (and hence the NULL pointer); make sure your code follows the conventions.
- For the C Programming Language: The lexical definitions and the full ANSI grammar.
- You will find previous midterms in the course notes for previous terms of this course. You will find links to all my courses in my home page.
- A Frequently Asked Questions file.
- Use the MEM package to find and reduce your dynamic memory problems. Read how to use it.
- A current list of marks, posted using your Alter Ego code names, is available.
The Scanner
- How to code the table in a table-driven lexical analyser.
- Recognizing keywords (reserved words) in a grammar.
- Using the union data type in C.
- The String token type.
- A fake Scanner used to test a Parser
The fake Scanner doesn't read any files or do any lexical analysis. It just contains a compiled-in table of tokens to return. Each time it is called, it returns the next token in the table. You can use this fake scanner to test your Parser even if you don't have a working Scanner. Here's how to use it:
- Rename your existing scanner() function to something else, such as scanner_old(), or use #if 0/#endif to hide it in your source file.
- Copy this fake scanner source file into your scanner source file, giving you a new, fake version of scanner().
- Modify the compiled-in list of tokens in the fake scanner function to return the sequence you want your Parser to see. Each time your Parser calls the fake scanner(), it will get the next token out of the internal table.
The Parser
- Program Grammar #1. (Assignment 4)
- Program Grammar #2. (Assignment 5-6)
- Program Grammar #3. (Assignment 7)
- How to write a recursive-descent predictive parser.
- Panic-mode error recovery.
- The print statement.
Semantic Actions
- On inserting semantic action symbols in a grammar.
- Coding the action symbols.
- Stacks of structures.
The Symbol Table
- Semantic actions for Assignment Statments
- The Symbol Table functions
- Printing the symbol table: The dump statement
Click here if you want to know more about participating in online discussion.
I recommend you learn to use the NNTP News interface, with Options set to "See only new/unread messages".
Read the Course Announcements to keep up-to-date on course news.
If you have questions or comments about the course, post it to the Course Discussion news group.
To chat with other Algonquin students about non-course issues, post to the Algonquin Student Discussion news group.
CST 8152 Course Announcements
algonquinc.academic.courses.cst.8152.98w.announceNNTP News WWW Gate CST 8152 Course News Group: Questions, Answers, Comments, and Discussion
algonquinc.academic.courses.cst.8152.98w.discussionNNTP News WWW Gate Algonquin Student Discussion
algonquinc.students.generalNNTP News WWW Gate The Algonquin College News Server is located on the National Capital FreeNet, a non-profit community network supported by member donations.
Assignments are listed here as they become available:
Assignment Number Topic Due Assignment One the Buffer data structure 12:00 noon, Monday January 19 Assignment Two file handling 12:00 noon, Monday February 9 Assignment Three Lexical Analyser 12:00 noon, Friday March 6
The one-week late penalty is waived.Assignment Four The Parser 12:00 noon, Friday March 27
The one-week late penalty is waived.Assignment Five Panic-Mode error recovery 2pm, Monday April 6
The one-week late penalty is waived.Assignment Six Semantic Actions 6pm, Thursday April 30
This is the last date for marked submissions.Assignment Seven The Symbol Table Optional/Bonus Assignment
6pm, Thursday April 30
This is the last date for marked submissions.
Assignments must be submitted in a particular format.
Do three things:
- Be sure you have registered with my online marking system or I won't know who you are.
- Read the general assignment submission guidelines that apply to all my courses.
- Return here to continue to read the specific submission requirements for this course, given below:
The CST 8152 FIle and Function Headers
C Language program submissions in this course must adhere to the Algonquin Standard coding practices set out in the CST 8110 Blue Book. I accept variance from this standard in two areas: brace style (I also accept a consistent K&R brace style), and pseudocode (I want only a short, high-level description of your algorithm, as outlined below).
Each source file and major function of a submitted program in CST 8152 must have an Algonquin-style header with the following five familiar headings of information:
- The Purpose of the source file or function. What does this source file or function do? (Note that the purpose of the program is not always identical to the purpose of the assignment.)
- The History of the source file or function, which must itself include six things:
- your name
- your student number
- your email address
- the course number
- the current term (e.g. 97w, 98s)
- the date you began writing this source file or function
- Inputs (if not already mentioned in the Purpose) or PreConditions
- Outputs (if not already mentioned in the Purpose) or PostConditions
- Algorithm:
- I do not require detailed pseudocode at the start of each function. Keep the Algorithm description short, readable, and accurate.
- In the source file or function header I do require a high-level description of the Algorithm used in each function, with good comments describing each block of code in the function itself. Give an overview of the whole function; don't go into details about each source line.
- If the Algorithm description takes more than a screenful of text, either your function is too long or you are specifying too much detail!
Minor functions in a source file do not need a full header. Each source file does need a full header. The source file header identifies the file, so it should be the very first thing at the top of the file.
Here is a sample source file header for this course. It describes the overall program and gives the algorithm for the main() function that drives the overall program:
/* * PURPOSE: * Implement and test a Buffer data structure. * Use the data structure to read lines ending in a newline from * standard input. Print the lines and their lengths. * EOF, or the string "done", may be used to terminate input. * HISTORY: * Author: Ian! D. Allen #74210779 * EMail: idallen@freenet.carleton.ca * Course: CST 8152 Winter 1998 * Date: January 4, 1998 * INPUTS: * Reads characters from standard input. * OUTPUTS: * Prints lines and their lengths on standard output. * Prompts appear on standard error if the input is a terminal. * Error messages also appear on the standard error output. * ALGORITHM: * Allocate a buffer. * Loop: * Clear the buffer. * If input is from a terminal, prompt the user for a string. * Fill the buffer with all the characters up to newline or EOF. * Terminate the string with NUL character and print the string. * Break out if the string has the value "done" or on EOF. * Print the size to which the buffer grew. * Free the buffer. Return Success to the O/S. */Note that the algorithm is a high-level description of what the function does. It is short and clear.
Each of the two midterms is held in class, 50 minutes long, closed book; no calculators; no aids. No make-up midterms will be given. After the tests are marked and the marks posted, the midterms and answers will be available here in some format.
Aho, Sethi, Ullman; Compilers - Principles, Techniques & Tools; Addison-Wesley, 1988
Students with the 1986 printing of the book may find it adequate. The 1988 printing fixed some errors. The text looks something like this (not exactly as illustrated):
The text is also on reserve in the Algonquin Library at Rideau Campus.
Other References
- My C Programming Resource Page, leading to many other pages, including to course notes for other courses in C programming. Compiler students should pay particular attention to the notes on Algonquin C Programming.
- The Summer 1997 (97s) Course Notes for CST 8152 are still online. No resemblance to current or future courses in Compilers is claimed; but, you might find them interesting if you wonder what you're getting into here.
A current list of marks, posted using your Alter Ego code names, is available.
Last revised: Sunday September 27, 1998 01:07.
Email comments to Ian! D. Allen idallen@freenet.carleton.ca