Separated parser class nodes and began writing compile methods

This commit is contained in:
Thaum Rystra
2019-04-06 10:56:53 +02:00
parent d21827106c
commit b7b0ac9c00
14 changed files with 167 additions and 207 deletions

View File

@@ -0,0 +1,21 @@
import ParseNode from '/imports/parser/parseTree/ParseNode.js';
export default class ConstantNode extends ParseNode {
constructor({value, type, errors}){
super();
// string, number, boolean, numberArray, uncompiledNode
this.type = type;
this.value = value;
if (errors) this.errors = errors;
}
compile(){
return this;
}
reduce(){
if (this.type === 'numberArray'){
return this.value.reduce((total, num) => total + num, 0);
} else {
return this;
}
}
}