use std::path::PathBuf;
use thiserror::Error;
use crate::lexer::LexerError;
#[derive(Debug)]
pub struct CompileResult {
pub success: bool,
pub messages: Vec<String>,
}
#[derive(Debug, Clone)]
pub struct CompileOptions {
pub output_dir: PathBuf,
}
impl Default for CompileOptions {
fn default() -> Self {
Self {
output_dir: PathBuf::from("."),
}
}
}
#[derive(Error, Debug)]
pub enum CompilerError {
#[error("IO error: {0}")]
IoError(String),
#[error("Parse error: {0}")]
ParseError(String),
#[error("Unexpected token: {0}")]
UnexpectedToken(String),
#[error("Compilation error: {0}")]
CompilationError(String),
}
impl From<LexerError> for CompilerError {
fn from(err: LexerError) -> Self {
CompilerError::ParseError(err.to_string())
}
}
impl From<crate::ast::ModuleError> for CompilerError {
fn from(err: crate::ast::ModuleError) -> Self {
CompilerError::CompilationError(err.to_string())
}
}
pub type ParseError = CompilerError;
pub type Result<T> = std::result::Result<T, CompilerError>;