type Index = usize;
#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error)]
pub enum ParserError {
#[error(transparent)]
Expected(#[from] ExpectedError),
#[error(transparent)]
Numeric(#[from] NumericError),
}
#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error)]
pub enum ExpectedError {
#[error("Expected dot token '.', but got '{}'{}.",
.got.map(String::from).unwrap_or_else(|| "EOI".to_string()),
.at.map(|i| format!(" at {}", i)).unwrap_or_default())
]
Separator {
at: Option<Index>,
got: Option<char>,
},
#[error("Expected end of input, but got '{got}'{}.", .at.map(|i| format!(" at {}", i)).unwrap_or_default())]
EndOfInput {
at: Option<Index>,
got: char,
},
#[error("Expected numeric token (0-9), but got '{}'{}.",
.got.map(String::from).unwrap_or_else(|| "EOI".to_string()),
.at.map(|i| format!(" at {}", i)).unwrap_or_default())
]
Numeric {
at: Option<Index>,
got: Option<char>,
},
}
#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error)]
pub enum NumericError {
#[error("Number may not start with a leading zero, unless the complete component is '0'")]
LeadingZero,
#[error("Overflow: Found number component which would be larger than the maximum supported number (max={})", u64::MAX)]
Overflow,
}