CPS710 |
Assignment 4 | |
Evaluator - Part 1 |
Due: December 7 |
This should start familiarizing you with evaluation and the JJTree support for visitors.
The learning objectives covered in this assignment are: 6Cb (which automatically generates 6Ca and 6Db), 6Ba, and 6Ab. Some of these learning objectives will be identified in the description of this assignment, and some in the tests.
Unlike for previous programming assignments, solutions to this assignment will not be provided. You will therefore need to do most of this assignment as a base for the next two. However, you will be able to submit this assignment by itself or along with the other two. This is explained in the submission section.
mkdir 710A4 cd 710A4 mkdir Tests mkdir AST
cp ~cps710/public_html/doc/F2024/A4/Handouts/* . cp ~cps710/public_html/doc/F2024/A4/Handouts/src/* . mv SimpleNode.java ASTSome of the files are the same as the ones in the previous handouts, but TestHL.java, SimpleNode.java, makefile, t, and runtests have been modified for this assignment.
You need to decide whether you will work from your own assignment 3 solution or the one handed out.
cp ~cps710/public_html/doc/F2024/A4/Handouts/UseSolution/* .
VISITOR_EXCEPTION="Exception";
make -f ~cps710/public_html/doc/F2024/A4/Handouts/UseMyOwn/makeHLEval
make
You may want to change some of these ASTs in HL.jjt, but if you do so, be aware that you will also need to change HLEval manually to reflect these changes. You will also need to clean up some of the files in the AST directory manually.
Nonetheless, even though this is not necessary for the implementation of this assignment, you may do this if you wish, as long as you do not change the syntax or the semantics of HL.
Below are the components that you will need to implement in this assignment. As you do so, remember that, as with previous assignments, you can continue to assume that the HL programs are error free. This means that your program does not need to handle invalid situations yet.
We are proposing the following class infrastructure that will facilitate the implementation of the HL evaluator by taking advantage of the OOP nature of Java: In the src subdirectory of the Handouts directory you will find a fully implemented version of HLObject.java and skeleton files for the other two classes.
The first reason why HL needs its own classes is that this OOP infrastructure with overridden generic methods will naturally devolve all the evaluation work into the appropriate type of value. As a result, the HLEval methods can be very generic and do not need to perform any type checking.
The second reason is that the classes provided in Java that are naturally aligned with these two HL types, Integer and TreeSet respectively, do not have the all the features required by the HL semantics.
At first this will seem like an onerous infrastructure just to perform a few operations on integers and sets, but as soon as more functionality needs to be implemented, this organisation will pay off. As explained in the submission section, you can overwrite as much of this provided infrastructure if you want, but I encourage you to review what is already provided, as it is probably a lot less work to use it rather than coming up with your own, which may turn out not to be substantially different.
For this learning objective, you should implement eval visitors and supporting HLNumber and HLSet methods to evaluate
Hints:
The tests and results are in the Tests directory.
We will be testing your assignment using the following files provided in the Handouts/src directory: