Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1.  
  2. // Exp - a simple integer mathematical expression
  3. // Eric McCreath 2018
  4.  
  5. public abstract class Exp {
  6. abstract int evaluate(); // calculate the value of the expression
  7.  
  8. abstract String show(); // show an expression
  9.  
  10.  
  11. // In your solution you may only modify the static methods parse, parseExp, and parseTerm.
  12. // You may not modify the signatures of these methods.
  13. // You may not modify any other classes or methods.
  14. // You may not add any fields or methods to this abstract class.
  15. //<exp> ::= <term> | <exp> + <term> | <exp> - <term>
  16. //<term> ::= ( <exp> ) | <integer literal>
  17. public static Exp parse(Tokenizer t) throws ParseException {
  18. // add code in this method for your solution
  19. return null;
  20. }
  21.  
  22. private static Exp parseExp(Tokenizer t) throws ParseException {
  23. // add code in this method for your solution
  24.  
  25. }
  26.  
  27.  
  28. private static Exp parseTerm(Tokenizer t) throws ParseException {
  29. // add code in this method for your solution
  30.  
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement