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 = 85 midterm1 = 85.00 >>> midterm1 = 90 midterm1 = 90.00 >>> midterm2 = 100 midterm2 = 100.00 >>> midterm2 = 70 midterm2 = 70.00 >>> midtermAvg[i=1-2] = (midterm1[i] + midterm2[i]) / 2 midtermAvg = 92.50 midtermAvg = 80.00 >>> midterm1 = 95 midterm1 = 95.00Notice that when I modified midterm1 at the end of the example the interpreter did not re-evaluated midtermAvg even though midtermAvg depends on midterm1'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 = final Error: final is undefined final = undef >>> final = foo Error: foo is undefined final = undefHere is another example:
>>> midterm = 50 midterm = 50.00 >>> midterm = 100 midterm = 100.00 >>> comp = min(midterm, midterm, midterm) Error: midterm is undefined comp = 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