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

View File

@@ -1,6 +1,6 @@
import NodeFactory from '/imports/parser/parseTree/NodeFactory';
import ParseNode from '/imports/parser/parseTree/ParseNode';
import { Context, ResolvedResult } from '/imports/parser/resolve';
import ResolveLevelFunction from '/imports/parser/types/ResolveLevelFunction';
import ToStringFunction from '/imports/parser/types/ToStringFunction';
export type ErrorNode = {
parseType: 'error';
@@ -8,17 +8,10 @@ export type ErrorNode = {
error: string;
}
interface ErrorFactory extends NodeFactory {
interface ErrorFactory {
create(node: Partial<ErrorNode>): ErrorNode;
compile(
node: ErrorNode, scope: Record<string, any>, context: Context
): ResolvedResult;
roll?: undefined;
reduce?: undefined;
resolve?: undefined;
toString(node: ErrorNode): string;
traverse?: undefined;
map?: undefined;
compile: ResolveLevelFunction<ErrorNode>;
toString: ToStringFunction<ErrorNode>;
}
const error: ErrorFactory = {
@@ -29,7 +22,7 @@ const error: ErrorFactory = {
error,
}
},
compile(node, scope, context) {
async compile(node, scope, context) {
return { result: node, context };
},
toString(node) {