Continued work on parser, now calling functions and rolling correctly
This commit is contained in:
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user