Make the following modifications to Parser.java (from the calculator program).
- Modify all of the eval methods for the Expr class and all of its subclasses Tree.java to take an argument x of type double. This will be ignored in the eval method except in the VariableExpr class (see below).
- Add a class to Tree.java for a FunctionExpr. It should have two fields, the function (of type Function) and the argument (of type Expr). Include a constructor and a toString method that prints out the object in a manner similar to the toString methods for the other types of nodes in the tree. You must also define an eval method.
- Add a class to Tree.java for a VariableExpr. No fields are needed, so no constructor is needed. Write an appropriate toString method. You must also define an eval method.
- In Parser.java, add a case to the parsePriExpr method to handle functions. The function call looks like sin(1+2*3) (that is, a token of type FUNCTION followed by a left parenthesis followed by an expression followed by a right parenthesis). It should return an object of type FunctionExpr.
- Add a case to the parsePriExpr method to handle variables (that is, tokens of type VARIABLE). It should return an object of type VariableExpr.