formula -> ID[NUMBER] = Exp NEWLINEand all expressions except for sum, min, and max. You will note that sum, min, and max require celllists as parameters. The interim due date does not require you to handle RowLists or CellLists.
>>> midterm1[1] = 85 midterm1[1] = 85.00 >>> midterm1[2] = 90 midterm1[2] = 90.00 >>> midterm2[1] = 100 midterm2[1] = 100.00 >>> midterm2[2] = 70 midterm2[2] = 70.00 >>> midtermAvg[i=1-2] = (midterm1[i] + midterm2[i]) / 2 midtermAvg[1] = 92.50 midtermAvg[2] = 80.00 >>> midterm1[1] = 95 midterm1[1] = 95.00Notice that when I modified midterm1[1] at the end of the example the interpreter did not re-evaluated midtermAvg[1] even though midtermAvg[1] depends on midterm1[1]'s value.
Your interpreter should use your Antlr parser to parse each line of input and create an expression tree for the formula. The expression tree should then be assigned to the appropriate cell(s). I would recommend storing the column names (e.g., midterm1, midterm2, midtermAvg) in a hash table and associating an array of cells with each column name. You should not have to duplicate an expression tree for each cell to which it is assigned. Your team should figure out a way to re-use an expression tree for multiple rows in a column.
If your interpreter encounters an undefined cell while evaluating a formula, it should print an error message indicating that the cell is undefined and mark as undefined the cell to which the formula is assigned. For example:
>>> final[1] = final[2] Error: final[2] is undefined final[1] = undef >>> final[1] = foo[1] Error: foo[1] is undefined final[1] = undefHere is another example:
>>> midterm[1] = 50 midterm[1] = 50.00 >>> midterm[2] = 100 midterm[2] = 100.00 >>> comp[1] = min(midterm[1], midterm[2], midterm[3]) Error: midterm[3] is undefined comp[1] = undef
If you have a question about the output your interpreter should generate you can test your input with my test interpreter, which can be invoked by typing:
java -jar /home/bvz/cs365/project/project2/formula.jarYou will not be able to copy this jar file to your personal computer because it contains a manifest.txt file that access the /usr/share/java/antlr3.jar file on the system. Since that directory and file does not exist on your pc, the jar file will not work on your pc.
Main-Class: formula.interpreter Class-Path: /usr/share/java/antlr3.jar