CST 8152 - Assignment 6

Program output due in Labs, July 30-31, 1997

Date Assigned: Monday, July 14, in class
Last Update: Sunday September 27, 1998 01:06
Due date extended: Monday July 21, in class


Note that this assignment does not require a symbol table. The symbol table is implemented in the final assignment, Assignment 7, whose output and source code is due August 6-7. The due date for the final assignment cannot be extended.

In this assignment you implement the semantic expression value stack that is part of your design for the semantic actions in the Toy Language interpreter. To get readable output from your program, you must also implement the Print statement and the STRING lexical token type.

Next assignment, you implement the Symbol Table to hold the results of the expressions you parse.


Following the code outline given in the class notes, design, write, and thoroughly test a semantic expression value stack and the associated arithmetic operations that handle numeric expressions. A sample stack is available. (Test the stack itself thoroughly, on its own, before you use it in your parser!)

Without a symbol table, we cannot save the value of expressions in variables. This limits testing at this stage to one-line statements containing only constant numbers and strings (no variables). The Print statement is the most convenient way to print the values of these expressions.

Develop test files that use the Print statement to print complex numeric and string constant expressions to verify that your stack and expression handling works. (No symbol table is needed to do this.) Invalid type expressions (e.g. adding a number to a string) must be detected by semantic analysis of operands at run time.

You will need to enhance your scanner to recognize some new token types. Your parser will need some new functions to handle the new non-terminals in the Toy Language.

Important Notes

Memory management

Clearing the stack

Run-time semantic checking

See also the important notes from Assignment Four.

Deliverables for this assignment

At the beginning of each Lab period on the dates given above, I will give each Lab section the URL of a different test input file consisting of many "print" statements and constant expressions. You must run the input file against your program and print and hand in the output of your program. (Please identify your output using the usual assignment submission guidelines.)

Keep your source code for this assignment (and all assignments this term). I will show you how to deposit your assignment source code into a directory on the Algonquin server when the server is ready. All assignment source code will be collected for analysis later in the term.

Ian D. Allen CST 8152 Home Page