1
2
3
4
5
6
7
8
9
10
11
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use pest::error::Error;
use snafu::{Backtrace, IntoError, Snafu};
use super::Rule;
#[derive(Snafu, Debug)]
#[snafu(context(suffix(false)), visibility(pub(super)))]
#[non_exhaustive]
pub enum ParseError {
#[snafu(display("an immediate value was too large for the given opcode"))]
#[non_exhaustive]
ImmediateTooLarge {
backtrace: Backtrace,
},
#[snafu(display("lexing failed"))]
#[non_exhaustive]
Lexer {
source: Box<dyn std::error::Error>,
backtrace: Backtrace,
},
#[snafu(display("expected {} argument(s) but only got {}", expected, got))]
#[non_exhaustive]
MissingArgument {
expected: usize,
got: usize,
backtrace: Backtrace,
},
#[snafu(display("extra argument (expected {})", expected))]
#[non_exhaustive]
ExtraArgument {
expected: usize,
backtrace: Backtrace,
},
#[snafu(display("incorrect argument type"))]
#[non_exhaustive]
ArgumentType {
backtrace: Backtrace,
},
}
impl From<Error<Rule>> for ParseError {
fn from(err: Error<Rule>) -> Self {
Lexer {}.into_error(Box::new(err))
}
}