1use std::{error, fmt};
5
6#[cfg_attr(not(debug_assertions), deny(warnings))]
7pub mod ast;
8pub mod emit;
9pub mod parser;
10pub mod token;
11
12#[derive(Debug, Clone)]
13pub struct Error(pub String);
14
15impl fmt::Display for Error {
16 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17 write!(f, "{}", self.0)
18 }
19}
20
21impl error::Error for Error {}
22
23pub fn transpile(sql: &str) -> Result<String, Error> {
24 let tokens = token::tokenize(sql)?;
25 let ast = parser::Parser::new(tokens).parse()?;
26 let rql = emit::emit(&ast)?;
27 Ok(rql)
28}