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