Lots of work on the parser including testing interface

This commit is contained in:
Stefan Zermatten
2020-09-09 17:09:50 +02:00
parent 445171ce80
commit 81645df2a6
15 changed files with 341 additions and 39 deletions

View File

@@ -11,11 +11,13 @@ export default class ConstantNode extends ParseNode {
compile(){
return this;
}
reduce(){
if (this.type === 'numberArray'){
return this.value.reduce((total, num) => total + num, 0);
} else {
return this;
}
toString(){
return `${this.value}`;
}
get isNumber(){
return this.type === 'number';
}
get isInteger(){
return this.isNumberNode && Number.isInteger(this.value);
}
}