1mod anre;
8mod ast;
9mod charwithposition;
10mod compiler;
11mod errorprinter;
12mod instance;
13mod location;
14mod peekableiter;
15mod printer;
16mod rulechecker;
17mod tradition;
18mod transition;
19mod utf8reader;
20
21pub mod process;
22pub mod route;
23
24pub use process::Regex;
25
26use std::fmt::{self, Display};
27
28use crate::location::Location;
29
30#[derive(Debug, PartialEq, Clone)]
31pub enum AnreError {
32 SyntaxIncorrect(String),
33 UnexpectedEndOfDocument(String),
34
35 MessageWithLocation(String, Location),
39}
40
41impl Display for AnreError {
42 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
43 match self {
44 AnreError::SyntaxIncorrect(msg) => f.write_str(msg),
45 AnreError::UnexpectedEndOfDocument(detail) => {
46 writeln!(f, "Unexpected to reach the end of document.")?;
47 write!(f, "{}", detail)
48 }
49 AnreError::MessageWithLocation(detail, location) => {
50 writeln!(
51 f,
52 "Error at line: {}, column: {}",
53 location.line + 1,
54 location.column + 1
55 )?;
56 write!(f, "{}", detail)
57 }
58 }
59 }
60}
61
62impl std::error::Error for AnreError {}