2024-08-07 02:11:38 +08:00
|
|
|
import type { QueryExpression } from "@silverbulletmd/silverbullet/types";
|
|
|
|
import { parseTreeToAST } from "@silverbulletmd/silverbullet/lib/tree";
|
2024-07-30 03:21:16 +08:00
|
|
|
import { expressionLanguage } from "$common/template/template_parser.ts";
|
2024-08-07 02:11:38 +08:00
|
|
|
import { expressionToKvQueryExpression } from "@silverbulletmd/silverbullet/lib/parse_query";
|
2024-07-30 03:21:16 +08:00
|
|
|
import { lezerToParseTree } from "$common/markdown_parser/parse_tree.ts";
|
|
|
|
|
|
|
|
export function parseExpression(s: string): QueryExpression {
|
2024-08-02 23:14:40 +08:00
|
|
|
const ast = parseTreeToAST(
|
|
|
|
lezerToParseTree(s, expressionLanguage.parser.parse(s).topNode),
|
|
|
|
);
|
|
|
|
return expressionToKvQueryExpression(ast[1]);
|
2024-07-30 03:21:16 +08:00
|
|
|
}
|