use sql_dialect_fmt_syntax::SyntaxKind;
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct Token<'a> {
pub kind: SyntaxKind,
pub text: &'a str,
}
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct LexError {
pub message: String,
pub offset: usize,
pub len: usize,
}
impl LexError {
pub fn range(&self) -> std::ops::Range<usize> {
self.offset..self.offset + self.len
}
}
impl std::fmt::Display for LexError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{} at byte {}", self.message, self.offset)
}
}
impl std::error::Error for LexError {}
#[derive(Clone, Debug, Default)]
pub struct Lexed<'a> {
pub tokens: Vec<Token<'a>>,
pub errors: Vec<LexError>,
}