Files
nand2tetris/web-ide-main/extension/src/languages/tst.ts
T
2026-04-09 14:14:56 +02:00

24 lines
681 B
TypeScript

import type { TST } from "@nand2tetris/simulator/languages/tst";
import { Diagnostic, TextDocument, Uri } from "vscode";
import * as base from "./base.js";
let tst: typeof TST | undefined = undefined;
async function getTst(): Promise<typeof TST> {
if (tst) return Promise.resolve(tst);
tst = (await import("@nand2tetris/simulator/languages/tst.js"))
.TST as typeof TST;
return tst;
}
export async function getDiagnostics(
document: TextDocument,
): Promise<[Uri, Diagnostic[]][]> {
try {
const { parser } = await getTst();
return base.getDiagnostics(document, parser);
} catch (e) {
console.error("Failed to load tst parser", e);
return [];
}
}