Skip to main content

reifydb_sql/
lib.rs

1// SPDX-License-Identifier: AGPL-3.0-or-later
2// Copyright (c) 2025 ReifyDB
3
4pub mod ast;
5pub mod emit;
6pub mod parser;
7pub mod token;
8
9#[derive(Debug, Clone)]
10pub struct Error(pub String);
11
12impl std::fmt::Display for Error {
13	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14		write!(f, "{}", self.0)
15	}
16}
17
18impl std::error::Error for Error {}
19
20pub fn transpile(sql: &str) -> Result<String, Error> {
21	let tokens = token::tokenize(sql)?;
22	let ast = parser::Parser::new(tokens).parse()?;
23	let rql = emit::emit(&ast)?;
24	Ok(rql)
25}