2024-02-09 04:00:45 +08:00
|
|
|
import { syscall } from "../syscall.ts";
|
2024-02-29 22:23:05 +08:00
|
|
|
import type { ParseTree } from "../lib/tree.ts";
|
2023-10-03 20:16:33 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Parses a piece of code using any of the supported SB languages, see `common/languages.ts` for a list
|
|
|
|
* @param language the language to parse
|
|
|
|
* @param code the code to parse
|
|
|
|
* @returns a ParseTree representation of the code
|
|
|
|
*/
|
|
|
|
export function parseLanguage(
|
|
|
|
language: string,
|
|
|
|
code: string,
|
|
|
|
): Promise<ParseTree> {
|
|
|
|
return syscall("language.parseLanguage", language, code);
|
|
|
|
}
|
2023-10-04 23:14:24 +08:00
|
|
|
|
2024-08-07 19:27:25 +08:00
|
|
|
/**
|
|
|
|
* Lists all supported languages in fenced code blocks
|
|
|
|
* @returns a list of all supported languages
|
|
|
|
*/
|
2023-10-04 23:14:24 +08:00
|
|
|
export function listLanguages(): Promise<string[]> {
|
|
|
|
return syscall("language.listLanguages");
|
|
|
|
}
|