Began work on rewriting parser without object orientation
Parsing is expensive, if the parse tree can be stored on the DB it can save a lot of compute time, but mongo can't store Classes, so we re-write without classes
This commit is contained in:
18
app/imports/parser/parseTree/constant.js
Normal file
18
app/imports/parser/parseTree/constant.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const constant = {
|
||||
create({value, valueType}){
|
||||
if (!valueType) throw `Expected valueType to be set, got ${valueType}`
|
||||
return {
|
||||
type: 'constant',
|
||||
valueType,
|
||||
value,
|
||||
}
|
||||
},
|
||||
compile(node){
|
||||
return node;
|
||||
},
|
||||
toString(node){
|
||||
return `${node.value}`;
|
||||
},
|
||||
}
|
||||
|
||||
export default constant;
|
||||
Reference in New Issue
Block a user