-
Notifications
You must be signed in to change notification settings - Fork 0
/
BooleanNode.ts
42 lines (35 loc) · 944 Bytes
/
BooleanNode.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { Expression } from "../Expression";
import { Scope } from '../structural/Scope';
export class BooleanNode extends Expression<BooleanNode>{
/**
* Constructor for BooleanNode, a node representing a boolean
* @param val The boolean value of the BooleanNode
* @param ws Preceding white space
*
*/
constructor(private _val: boolean, ws: string = "") {
super(ws);
};
/**
* Returns the BooleanNode
* @param context The current program context
*/
eval(context: Scope): BooleanNode {
return this;
}
equals(right: Expression<any>): boolean {
if (right instanceof BooleanNode) {
return this.val === right.val;
}
return false;
}
toString(): string {
return this.ws + this.val;
}
get val(): boolean {
return this._val;
}
set val(value: boolean) {
this._val = value;
}
}