In this recitation assignment, you are given the definition of a Class, calledValue, which represents values of operands in the language to implement its interpreter in Programming Assignment 3. These...


In this recitation assignment, you are given the definition of a Class, calledValue, which represents values of operands in the language to implement its interpreter in Programming Assignment 3. These include values for the three defined types in the language: INT, FLOAT, and BOOL, as well as the string literal. The objective of defining theValueclass is to facilitate constructing an interpreter for the language which evaluates expressions and executes statements using C++.


In RA 8, you are required to implement some of the overloaded operators of theValueclass in order to enable testing this class separately as a unit before using it in the construction of the interpreter in PA3. You are required to implement the overloaded operators for Subtraction, Multiplication, Less-Than, and AND operations. The semantic rules governing the evaluation of expressions in the language are summarized below:



  • The binary operations for addition, subtraction, multiplication, and division are performed upon two numeric operands (i.e., INT, FLOAT) of the same or different types. If the operands are of the same type, the type of the result is the same type as the operator’s operands. Otherwise, the type of the result is FLOAT.

  • The binary logic operations for the AND and OR operators are applied on two Boolean operands only.

  • The LTHAN and GTHAN relational operators and the EQUAL operator operate upon two operands of compatible types. The evaluation of a relational expression, based on LTHAN or GTHAN operators, or an Equality expression, based on the Equal operator, produce either a true or false value.

  • The unary sign operators (+ or -) are applied upon one numeric operand (i.e., INT, FLOAT). While the unary NOT operator is applied upon a one Boolean operand (i.e., BOOL).

Nov 18, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here