Open Tientuine opened 1 year ago
@Stubeans It turns out that I approved and merged your PR prematurely. Can you make the changes described below and then open another PR? Thanks.
valueOf
rule. The correct constructor name is BinaryExpr
, not BinaryExp
.valueOf
rule. It needs to be an Answer
, which is a pair containing a value and a store. Right now you're just returning the value, and the store is missing.undefined
case for valueOf
to below your case, otherwise the interpreter will never reach your case.With these few fixes, this will be done.
@Stubeans Bump.
@Stubeans It turns out that I approved and merged your PR prematurely. Can you make the changes described below and then open another PR? Thanks.
1. Fix the pattern for binary expression on the left-hand side of your `valueOf` rule. The correct constructor name is `BinaryExpr`, not `BinaryExp`. 2. Fix the return value on the right-hand side of your `valueOf` rule. It needs to be an `Answer`, which is a pair containing a value and a store. Right now you're just returning the value, and the store is missing. 3. Finally, move the `undefined` case for `valueOf` to below your case, otherwise the interpreter will never reach your case.
With these few fixes, this will be done.
@Marist-CMPT331-TOPL/students
The interpreter should be able to handle binary operations by implementing the corresponding semantic rule(s) to compute an
Answer
. This is one part of a multi-part task that should be divided up among several people, coordinated carefully.valueOfBop
that takes aBinaryOp
and two expressed values and returns an appropriate expressed value. Initially leave this function undefined, so that each case may be implemented by various people.valueOf
forBinaryExpr
that relies on the helpervalueOfBop
function. This implementation should compute the values of the two operand expressions, accounting for state changes appropriately, and then pass the values into the helper function.