Typescript all the parser things

This commit is contained in:
Thaum Rystra
2024-02-20 23:21:12 +02:00
parent 3ea492ee78
commit ac15512bc5
86 changed files with 926 additions and 718 deletions

15
app/imports/parser/map.ts Normal file
View File

@@ -0,0 +1,15 @@
import nodeTypeIndex from './parseTree';
import ParseNode from '/imports/parser/parseTree/ParseNode';
export default async function map(node: ParseNode, fn: (ParseNode) => Promise<any>): Promise<any> {
if (!node) return;
const type = nodeTypeIndex[node.parseType];
if (!type) {
console.error(node);
throw new Meteor.Error('Not valid parse node');
}
if ('map' in type) {
return type.map(node as any, fn, map);
}
return fn(node);
}