Finished migrating parser to be object orientation free. All tests pass

This commit is contained in:
Stefan Zermatten
2021-10-03 13:54:17 +02:00
parent d30184434c
commit b78517b61f
35 changed files with 589 additions and 654 deletions

View File

@@ -3,7 +3,7 @@ import constant from './constant.js';
const accessor = {
create({name, path}) {
return {
type: 'accessor',
parseType: 'accessor',
path,
name,
};
@@ -45,12 +45,11 @@ const accessor = {
},
reduce(node, scope, context){
let { result } = accessor.compile(node, scope, context);
if (result.type === 'accessor'){
if (result.parseType === 'accessor'){
context.error(`${accessor.toString(result)} not found, set to 0`);
return {
result: constant.create({
value: 0,
valueType: 'number',
}),
context
};