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").