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
70
71
72
73
74
75
76
77
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum LexErrorMsg {
GroupNonCapturing,
GroupLookahead,
GroupLookaheadNeg,
GroupLookbehind,
GroupLookbehindNeg,
GroupNamedCapture,
GroupPcreBackreference,
GroupComment,
GroupAtomic,
GroupConditional,
GroupBranchReset,
GroupSubroutineCall,
GroupOther,
Backslash,
BackslashU4,
BackslashX2,
BackslashUnicode,
BackslashProperty,
BackslashGK,
UnclosedString,
DeprStart,
DeprEnd,
}
impl LexErrorMsg {
pub fn get_help(&self, slice: &str) -> Option<String> {
super::diagnostics::get_parse_error_msg_help(*self, slice)
}
}
impl std::error::Error for LexErrorMsg {}
impl core::fmt::Display for LexErrorMsg {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let error = match self {
LexErrorMsg::GroupNonCapturing
| LexErrorMsg::GroupLookahead
| LexErrorMsg::GroupLookaheadNeg
| LexErrorMsg::GroupLookbehind
| LexErrorMsg::GroupLookbehindNeg
| LexErrorMsg::GroupNamedCapture
| LexErrorMsg::GroupPcreBackreference
| LexErrorMsg::GroupOther => "This syntax is not supported",
LexErrorMsg::GroupComment => "Comments have a different syntax",
LexErrorMsg::GroupAtomic => "Atomic groups are not supported",
LexErrorMsg::GroupConditional => "Conditionals are not supported",
LexErrorMsg::GroupBranchReset => "Branch reset groups are not supported",
LexErrorMsg::GroupSubroutineCall => "Subroutines are not supported",
LexErrorMsg::Backslash
| LexErrorMsg::BackslashU4
| LexErrorMsg::BackslashX2
| LexErrorMsg::BackslashUnicode
| LexErrorMsg::BackslashProperty
| LexErrorMsg::BackslashGK => "Backslash escapes are not supported",
LexErrorMsg::UnclosedString => "This string literal doesn't have a closing quote",
LexErrorMsg::DeprStart => "The `<%` literal is deprecated.",
LexErrorMsg::DeprEnd => "The `%>` literal is deprecated.",
};
f.write_str(error)
}
}