xee_xpath_compiler/
compile.rs1use xee_interpreter::{context, error, interpreter::Program};
2use xee_ir::{compile_xpath, Variables};
3use xee_xpath_ast::ast;
4
5use crate::ast_ir::IrConverter;
6
7pub fn compile(
9 static_context: context::StaticContext,
10 xpath: ast::XPath,
11) -> error::SpannedResult<Program> {
12 let mut variables = Variables::new();
13 let mut ir_converter = IrConverter::new(&mut variables, &static_context);
14 let expr = ir_converter.convert_xpath(&xpath)?;
15 compile_xpath(expr, static_context)
16}
17
18pub fn parse(static_context: context::StaticContext, xpath: &str) -> error::SpannedResult<Program> {
20 let xpath = static_context.parse_xpath(xpath)?;
21 compile(static_context, xpath)
22}