1
0

infixApp.js 431 B

12345678910111213141516171819202122
  1. import { Expression } from './expression';
  2. export class InfixApp extends Expression {
  3. constructor(op, left, right) {
  4. super();
  5. this.op = op;
  6. this.left = left;
  7. this.right = right;
  8. }
  9. toString () {
  10. const l = this.left.toString();
  11. const op = this.op.value;
  12. const r = this.right.toString();
  13. if(this.parenthesis) {
  14. return `(${l + op + r})`;
  15. } else {
  16. return l + op + r;
  17. }
  18. }
  19. }