use dsntk_common::{DsntkError, ToErrorMessage};
#[derive(ToErrorMessage)]
struct LexerError(String);
pub fn err_unexpected_eof() -> DsntkError {
LexerError("unexpected end of file".to_string()).into()
}
pub fn err_expected_hex_digit(ch: char) -> DsntkError {
LexerError(format!("expected hex digit but encountered '{ch}'")).into()
}
pub fn err_unicode_value_out_of_range(value: u64) -> DsntkError {
LexerError(format!("value is out of allowed Unicode range 0x0000..0x10FFFF : {value:X}")).into()
}
pub fn err_unicode_surrogate_out_of_range(value: u64) -> DsntkError {
LexerError(format!("surrogate value is out of allowed range 0xD800..0xDFFF : {value:X}")).into()
}
#[derive(ToErrorMessage)]
struct ParserError(String);
pub fn err_not_a_feel_name(s: &str) -> DsntkError {
ParserError(format!("expected `FEEL` name on input but found `{s}`")).into()
}
pub fn err_syntax_error(input: &str) -> DsntkError {
ParserError(format!("syntax error: {input}")).into()
}