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
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("io error: {0}")]
IoErr(#[from] ::std::io::Error),
#[error("line {0} is missing a space and so cannot be properly split")]
InvalidLine(usize),
#[error("rule parse error: {0}")]
RuleParseError(#[from] ParseError),
}
pub type Result<T> = ::std::result::Result<T, Error>;
#[derive(Debug, Clone, thiserror::Error, PartialEq)]
pub enum ParseError {
#[error("Expected stress marker '0', '1', or '2', got {0}")]
ExpectedStress(char),
#[error("Expected {0}, got EOF")]
UnexpectedEOF(&'static str),
#[error("Expected {0} after {1}, got EOF")]
UnexpectedEOFAfter(&'static str, &'static str),
#[error("Expected {0}, got {1}")]
UnexpectedCharacter(&'static str, char),
#[error("Expected {0} after {1}, got {2}")]
UnexpectedCharacterAfter(&'static str, &'static str, char),
}
pub type ParseResult<T> = ::std::result::Result<T, ParseError>;