s6.l and s6.y provide the skeleton of your project. There are a few things
that are not implemented. You have to implement them and that will complete
your project. There are three tables in this project - Symbol Table, string table and a Tree Table (tree is embedded in a table with 5 entries - operator and
two operands and the tables where the operands are located). The convention
I have used: 0 referes to Symbol Table, 1 refers to Tree Table and 2 refers
to String Table. For example, the following statements
modcomp=2004;
grade=100;
print "My Grade is A as my score is=";
score = grade*modcomp;
print score;
print newline;
This is the tree. The first two entries in the tree implement modcomp=2004. The first tree entry
evaluates by loading from the symbol table (0) entry 2. The second tree entry evaluates the first entry(0) of the tree table
(1) and stores in the first entry (1) of the symbol table(0). You can follow the rest of the tree.
mytree (0 ) (L 0 2 0 0 )
mytree (1 ) (= 0 1 1 0 )
mytree (2 ) (L 0 4 0 0 )
mytree (3 ) (= 0 3 1 2 )
mytree (4 ) (; 1 1 1 3 )
mytree (5 ) (p 2 1 0 0 )
mytree (6 ) (; 1 4 1 5 )
mytree (7 ) (L 0 3 0 0 )
mytree (8 ) (L 0 1 0 0 )
mytree (9 ) (* 1 7 1 8 )
mytree (10 ) (= 0 5 1 9 )
mytree (11 ) (; 1 6 1 10 )
mytree (12 ) (L 0 5 0 0 )
mytree (13 ) (P 1 12 0 0 )
mytree (14 ) (; 1 11 1 13 )
mytree (15 ) (q 2 5 0 0 )
mytree (16 ) (; 1 14 1 15 )
Output
My Grade is A as my score is=200400
Symbol Table
1: modcomp 2004
2: 2004 2004
3: grade 100
4: 100 100
5: score 200400
String table
My Grade is A as my score is=