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