mod anre;
mod ast;
mod charwithposition;
mod compiler;
mod errorprinter;
mod instance;
mod location;
mod peekableiter;
mod printer;
mod rulechecker;
mod tradition;
mod transition;
mod utf8reader;
pub mod process;
pub mod route;
pub use process::Regex;
use std::fmt::{self, Display};
use crate::location::Location;
#[derive(Debug, PartialEq, Clone)]
pub enum AnreError {
SyntaxIncorrect(String),
UnexpectedEndOfDocument(String),
MessageWithLocation(String, Location),
}
impl Display for AnreError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
AnreError::SyntaxIncorrect(msg) => f.write_str(msg),
AnreError::UnexpectedEndOfDocument(detail) => {
writeln!(f, "Unexpected to reach the end of document.")?;
write!(f, "{}", detail)
}
AnreError::MessageWithLocation(detail, location) => {
writeln!(
f,
"Error at line: {}, column: {}",
location.line + 1,
location.column + 1
)?;
write!(f, "{}", detail)
}
}
}
}
impl std::error::Error for AnreError {}