Project Description In this project, you will implement recursive descent parser discussed in the class. Add the following method to Num class.
static Num evaluateExp(String expr): parse/evaluate the given expression and return the resulting number. You need to implement the recursive descent parser discussed in the class. Assume that the grammar is the same as the one we discussed in the class. If the given string is not valid, i.e., not a string that can be generated by the grammar, the method should throw an exception. The operands and operators in the input string may or may not be separated by empty space. For example, both “(3+4) * 5” and “( 3 + 4 ) *5” are valid inputs.
The numbers in the expression can be of arbitrary length. Use Num. If there are ‘-‘ and/or ‘/’ operators in the expression, throw unsupported operator exception.
Use StringBuilder to tokenize the input string, as strings are immutable in Java.
The following methods are optional.
• static String toPostfix(String expr): Implement shunting yard algorithm • static Num evaluatePostfix(StringH expr): Evaluate an expression in postfix and return the resulting number.
- Phone+44 7868 815209
- Emailadmin@solvemyproject.com
- Open Hours24x7
- Phone+44 7868 815209
- Emailadmin@solvemyproject.com
- Open Hours24x7