use thiserror::Error;

use crate::frontend::types::{Token, TokenValue};

// #[derive(Debug, Clone, PartialEq, Eq, Error)]
// pub enum ParseError {
//     BlockStmt(#[from] BlockStmtError)
// }
// #[derive(Debug, Clone, PartialEq, Eq, Error)]
// pub enum BlockStmtError {
//     MissingLBrace,
//     MissingRBrace,
// }
#[derive(Debug, Clone, PartialEq, Eq, Error)]
pub enum LexingError {
    #[error("invalid int literal")]
    InvalidIntLiteral,
    #[error("invalid ident")]
    InvalidIdent,
    #[error("comment unterminated")]
    UnterminatedComment,
    #[error("unrecognized token: {0}")]
    UnrecognizedToken(String),
}
#[derive(Debug, Clone, PartialEq, Eq, Error)]
pub enum ParseError {
    #[error("unexpected token {}, expect {}", .0, .1)]
    UnexpectedToken(TokenValue, &'static str),
    #[error("cannot combine with previous {}", .0)]
    CantCombineWith(TokenValue),
    #[error("expect {0} after")]
    ExpectButEof(&'static str),
}
#[derive(Debug, Clone, PartialEq, Eq, Error)]
pub enum FrontendError {
    #[error(transparent)]
    Lexing(#[from] LexingError),
    #[error(transparent)]
    Parse(#[from] ParseError),
}