Newer
Older
pub use error::{
format_forge_error, print_forge_error, ForgeError, ForgeErrorKind, ParseError, ParseErrorKind,
TokenError, TokenErrorKind,
};
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
pub mod parse {
pub use super::lexer::{script_to_tokens, ScriptToken, ScriptTokenType};
pub use super::parser::ast;
pub use super::parser::{parse_expression, parse_program};
}
#[cfg(test)]
#[macro_export]
macro_rules! map_result {
($val: expr, $with: expr) => {
match $val {
Ok((remainder, token)) => $with(remainder, token),
Err(nom::Err::Incomplete(_)) => panic!("Incorrect error type"),
Err(nom::Err::Failure(err)) | Err(nom::Err::Error(err)) => {
panic!(
"At [{}:{}]: {}; Value ||{}||",
&err.input.location_line(),
&err.input.get_column(),
&err.code.description(),
&err.input
);
}
}
};
($val: expr, $with: expr, $printable: expr) => {
match $val {
Ok((remainder, token)) => $with(remainder, token),
Err(nom::Err::Incomplete(_)) => panic!("Incorrect error type"),
Err(nom::Err::Failure(err)) | Err(nom::Err::Error(err)) => {
panic!(
"At [{}:{}]: {}; Value {}",
&err.input.location_line(),
&err.input.get_column(),
&err.code.description(),
$printable
);
}
}
};
}