Continued work on parser, now calling functions and rolling correctly

This commit is contained in:
Stefan Zermatten
2020-09-10 00:14:24 +02:00
parent 81645df2a6
commit ede4e1367d
16 changed files with 243 additions and 88 deletions

View File

@@ -1,9 +1,10 @@
import ParseNode from '/imports/parser/parseTree/ParseNode.js';
import ConstantNode from '/imports/parser/parseTree/ConstantNode.js';
import ErrorNode from '/imports/parser/parseTree/ErrorNode.js';
export default class SymbolNode extends ParseNode {
constructor({name}){
super();
super(...arguments);
this.name = name;
}
toString(){
@@ -13,12 +14,11 @@ export default class SymbolNode extends ParseNode {
let value = scope && scope[this.name];
let type = typeof value;
if (type === 'string' || type === 'number' || type === 'boolean'){
return new ConstantNode({value, type});
return new ConstantNode({value, type, previousNodes: [this]});
} else if (type === 'undefined'){
return new ConstantNode({
value: this.name,
type: 'uncompiledNode',
errors: [`${this.name} could not be resolved`]
return new ErrorNode({
node: this,
error: `${this.name} could not be resolved`,
});
} else {
throw new Meteor.Error(`Unexpected case: ${this.name} resolved to ${value}`);