Wiki
Clone wikihopl-course / BETA-assignment
BETA assignment
This assignment will illustrate virtual classes, a concept introduced in BETA, in the language CaesarJ, see http://caesarj.org/ for more information. A solution to the expression problem in CaesarJ is described here. The described solution serves as a basis for assignment.
Installation
Login to VM
$ ssh user@pvggit.cs.lth.se
Make new directory for hopl
$ mkdir hopl
$ cd hopl
Copy skeleton code
$ cp -r /hopl/code/caesarj/expr .
Compile and execute program
$ cd expr
$ cjc expr/*.java
$ cj expr.Main_Impl
3
-3
1
Assignment
To complete this assignment:
- Study the skeleton code (located at the VM, see Installation)
- Add new data types
- Add support for subtraction, division and multiplication
- Add support for
let
expressions. For example, the expressionlet x=10 in x*2
should evaluate to 20. The expression does not need to be parsed, but can be created using ordinary code, for example, byLet("x", Lit(10), Mul(Var("x"), Lit(2)))
or similar. - Create a new class containing the new data types
- The signature of the
eval
method needs to be changed in order to handlelet
expressions.
- Add new operations
- Modulary add a
toString
method that converts an expression to a String (also called pretty printing)
- Modulary add a
Updated