Added commutative simplification for + and *

This commit is contained in:
ThaumRystra
2023-11-11 13:31:31 +02:00
parent 3b1f61aa0a
commit fbc8ed977a
3 changed files with 116 additions and 38 deletions

View File

@@ -23,8 +23,11 @@ export default function resolve(fn, node, scope, context = new Context()) {
export function toString(node) {
if (!node) return '';
if (!node.parseType) {
throw new Meteor.Error(`Node does not have a parseType defined, node is type ${typeof node} with parseType ${node.parseType}`)
}
let type = nodeTypeIndex[node.parseType];
if (!type.toString) {
if (!type?.toString) {
throw new Meteor.Error('toString not implemented on ' + node.parseType);
}
return type.toString(node);