Question: I have started this assignment but I am now stuck. I have created all classes in separate files instead of all in one. I need

I have started this assignment but I am now stuck. I have created all classes in separate files instead of all in one. I need help in the infix and postfix for the binop, unop, and constant

I have started this assignment but I am now stuck. I havecreated all classes in separate files instead of all in one. Ineed help in the infix and postfix for the binop, unop, and

Emcee Expressions Problem Description: Our Emcee language included expressions, as defined in the BNF below: expression constant identifier expression binary_op expression unary_op expression identifier LEFT_PAREN expression_list RIGHT PAREN identifier LEFT_PAREN RIGHT_PAREN LEFT PAREN expression RIGHT PAREN constant REAL CONST | INT CONST | STRING CONST binary_op : := PLUS | MINUS | MULT | DIVIDE | CARAT | MOD unary_op MINUS As we prepare to complete our Emcee interpreter, you are to create C++ classes that implement the portions highlighted above. For binary operators, you need only handle + -, * and /. Your unary operator should handle -. Constants are always integers. The design for these classes can be found below. Declare all your C++ classes in the file "expression.h". A reminder about expression notation: An infix expression places the operator between two operands, or in front of a single operand (e.g. 1 + 2, or - 3). A postfix expression always puts the operator after the operands (e.g. 1 2 +, or 3 u-). To avoid confusion, when printing a unary - in postfix format, use the notation u- (as shown above and also in the example below). When printing infix, use parentheses liberally (again, see example below) To test your classes, run the main program defined below. This program creates the following expression, evaluates it, and then prints it in infix and postfix formats: - 3 * (4 + (9 / 3 ) )Design: expression +eval(): int +infix(): char * +postfix(): char * constant unop Binop +constant([: int) +unop(op: char, e: expression *) +binop(op: char, el: expression *, e2: expression *) +eval(): int +eval(): int +eval(): int +infix(): char * +infix(): char +infix(): char +postfix(): char * +postfix(): char * +postfix(): char * Required Main: #include "expression. h" #include using namespace std; int main (int argo, char *argv ) { expression *e = new binop('*', new unop (' -', new constant (3) ) , new binop ( 't', new constant (4) , new binop ( ' / ', new constant (9) , new constant ( 3) cout eval () infix () postfix () // Includes declaration of sprintf() char expr str [100] ; sprintf (expr_str, " (8s :c :s) ", el. infix(), op, e2. infix() ) ; Required Input: . None Required Output: Your output should look like the following: Evaluate: -21 Infix: ((- 3) * (4 + (9 / 3) ) ) Postfix : 3 u- 4 9 3 / + *

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!