Computer Science 5641
Project Part 5 - An Interpreter (80 points)
Due December 13, 2002 (4pm, no late programs)
As the last part of your project you will build an interpreter for
the code produced from project part 4.
The interpreter should be called only if no errors are detected in previous
Execution should follow the following rules:
- Program execution should start be declaring all global variables and
then calculating any expression values for those variables.
- All variables should be initialized to 0 if no initialization expression
- After all variables are initialized the function main should be called.
- After main is finished the return value of the function main should be
- Errors should be detected in the following cases:
- Division by zero is attempted.
- A function call in an expression has no return value.
- The return value (if any) of a function call in a statement is ignored.
- +, -, *, and / operations work as in C++.
- The comparsion operators (==, !=, <, >, <=, >=) produce
an integer value of 1 of the condition is true and 0 if false.
- The && and || are short circuit and and or operators. Short circuit
means that the second operator is checked only if needed.
- The ! operator performs a not on integer values (if the value is
non-zero the result is 0 and if the value is zero the result is 1).
- Assignment statements are executed by determining the value of the
right-hand side expression and then storing it in the variable on the
- A write prints out an string representation of the value of the expression
(as if printed using the << in C++).
- A read statement applied to a variable attempts to read in a variable
of the appropriate type (as in the >> operator in C++).
- A readln statement reads characters from the input until the next
newline is encountered.
- An if statement determines the integer value of the condition, if it
is non-zero the statement following the condition is executed, if zero
the statement following the else (if any) is executed.
- A while statement is a loop where the condition value is determined,
and if the value is non-zero the statement is executed and then this
process is repeated.
What To Turn In
Turn in documented versions of all of your code (including test code).
Also document your test cases and show results from your code on each
You will likely need to construct many test files in order to fully
exercise your code.
You should also write a team report on this part of the project and in
addition submit a short individual report from each member of the team.