name:
src/main/js/models/nodes/BinaryOperationNode.ts
-rw-r--r--
621
1import { Node } from "./Node";
2import { NodeType } from "./NodeType";
3
4/**
5 * Represents a binary operation with a left and right node, and an operator. Eg: 10 * 20.
6 */
7export class BinaryOperationNode extends Object implements Node {
8 readonly type: NodeType = NodeType.BinaryOperation;
9 readonly left: Node;
10 readonly right: Node;
11 readonly operator: string;
12
13 constructor(left: Node, operator: string, right: Node) {
14 super();
15 this.left = left;
16 this.operator = operator;
17 this.right = right;
18 }
19
20 toString() {
21 return `${this.left.toString()} ${this.operator} ${this.right.toString()}`;
22 }
23}