CIS505 Assignment 7

10 points; due Wednesday, Dec. 15, 4:10pm (feel free to submit it sooner, but Dec. 15 is the last possible date)

Use Prolog to write an interpreter for the mini-C language of assignment 2.

You are given a partially finished interpreter. You will need to fill in all the blanks "...". There is a test file. After you have loaded the interpreter, load the test file and observe the result:

===================================================

XSB Version 3.2 (Kopi Lewak) of March 15, 2009
[i386-apple-darwin10.5.0; mode: optimal; engine: slg-wam; scheduling: local; word size: 64]

| ?- [interpreter].
[Compiling ./interpreter]
% Specialising partially instantiated calls to evalETREE/3
% Specialising partially instantiated calls to evalLTREE/3
[interpreter compiled, cpu time used: 0.0190 seconds]
[interpreter loaded]

yes
| ?- [testcases].
[Compiling ./testcases]
[testcases compiled, cpu time used: 0.0090 seconds]
[testcases loaded]
Test case 1:

final env: 
a->([int], 0)
final memory: 
0: 6

Test case 2:
6
final env: 
a->([int], 0)
final memory: 
0: 6

Test case 3:
200
final env: 
a->([int], 0)
b->([ptr,int], 1)
c->([ptr,int], 2)
final memory: 
1: 0
2: 0
0: 2

yes

===================================================
You do not need to report errors (such as type mismatches) in your program, although you are welcome to do so. When such errors happen, it is OK to simply fail in the interpretation (i.e. The interpreter returns with "no").

Submission

Submit to K-State Online a zipped folder containing your completed program. Also include a text-file log of the successful test cases and their outputs. You should test at least the three example programs included in the test file. Feel free to test more programs.