This assignment makes use of the files contained in this zip file.
This assignment is due Wednesday, September 29.
This assignment is based on the languages cs502-language-hw3 and cs502-language-7.
In this assignment, you will write an interpreter that implements while-loops and conditional-expressions. Also, your interpreter should implement a limited form of anonymous functions. In the zip file there is a text file cs502-language-hw4.txt that defines the syntax and semantics of the language you are to interpret. Read this description carefully.
The language defined in the file cs502-language-hw4.txt is a subset of the tree-language from the first homework assignment. A version of BuildTree.java from Assignment 1 is included in the zip file. Use it as the parser for this assignment's language.
In the zip file there is a file Evaluate.java that is supposed to be an interpreter for the language cs502-language-hw4 . You need to complete this interpreter.
Also in the zip file there is a file AST2infix.java which is supposed to format strings from the language cs502-language-hw4 in a "C like" notation that includes infix notation for arithmentic and boolean expressions. You need to complete this "translator". Your AST2infix.java program should use operator precedence to create an infix notation that uses the minimum number of needed parentheses.
The files Tokenizer.java , Tree.java , BuildTree.java , PrettyPrinter.java , Value.java , Environment.java , FunctionEnvironment.java , ParseException.java , and EvalException.java which are in the zip file, do not need to be modified. You should use them exactly as they are.
When you have finished implementing Evaluate.java and AST2infix.java , then the file Tests.java should compile and run. The output from running this program should look exactly like the file output.txt . Notice that Tests.java uses try-catch clauses to handle exceptions thrown by Evaluate.java . Your version of Evaluate.java should throw EvalException when it detects a runtime error. From the contents of the file output.txt you can see what kinds of runtime errors your Evaluate.java should be able to detect.
Turn in a zip file containing your versions of Evaluate.java , AST2infix.java , BuildTree.java , and PrettyPrint.java along with the other files from the zip file.
This assignment is due Wednesday, September 29.
|