diff options
Diffstat (limited to 'crates/ra_syntax/src/yellow')
-rw-r--r-- | crates/ra_syntax/src/yellow/syntax_error.rs | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/yellow/syntax_error.rs b/crates/ra_syntax/src/yellow/syntax_error.rs index f3df6bc15..c32ee650d 100644 --- a/crates/ra_syntax/src/yellow/syntax_error.rs +++ b/crates/ra_syntax/src/yellow/syntax_error.rs | |||
@@ -34,6 +34,10 @@ impl SyntaxError { | |||
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
37 | pub fn kind(&self) -> SyntaxErrorKind { | ||
38 | self.kind.clone() | ||
39 | } | ||
40 | |||
37 | pub fn location(&self) -> Location { | 41 | pub fn location(&self) -> Location { |
38 | self.location.clone() | 42 | self.location.clone() |
39 | } | 43 | } |
@@ -64,11 +68,31 @@ impl fmt::Display for SyntaxError { | |||
64 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 68 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
65 | pub enum SyntaxErrorKind { | 69 | pub enum SyntaxErrorKind { |
66 | ParseError(ParseError), | 70 | ParseError(ParseError), |
71 | UnescapedCodepoint, | ||
67 | EmptyChar, | 72 | EmptyChar, |
68 | UnclosedChar, | 73 | UnclosedChar, |
69 | LongChar, | 74 | OverlongChar, |
75 | EmptyByte, | ||
76 | UnclosedByte, | ||
77 | OverlongByte, | ||
78 | ByteOutOfRange, | ||
79 | UnescapedByte, | ||
80 | EmptyByteEscape, | ||
81 | InvalidByteEscape, | ||
82 | TooShortByteCodeEscape, | ||
83 | MalformedByteCodeEscape, | ||
84 | UnicodeEscapeForbidden, | ||
70 | EmptyAsciiEscape, | 85 | EmptyAsciiEscape, |
71 | InvalidAsciiEscape, | 86 | InvalidAsciiEscape, |
87 | TooShortAsciiCodeEscape, | ||
88 | AsciiCodeEscapeOutOfRange, | ||
89 | MalformedAsciiCodeEscape, | ||
90 | UnclosedUnicodeEscape, | ||
91 | MalformedUnicodeEscape, | ||
92 | EmptyUnicodeEcape, | ||
93 | OverlongUnicodeEscape, | ||
94 | UnicodeEscapeOutOfRange, | ||
95 | UnclosedString, | ||
72 | } | 96 | } |
73 | 97 | ||
74 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 98 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -78,11 +102,38 @@ impl fmt::Display for SyntaxErrorKind { | |||
78 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | 102 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
79 | use self::SyntaxErrorKind::*; | 103 | use self::SyntaxErrorKind::*; |
80 | match self { | 104 | match self { |
105 | UnescapedCodepoint => write!(f, "This codepoint should always be escaped"), | ||
81 | EmptyAsciiEscape => write!(f, "Empty escape sequence"), | 106 | EmptyAsciiEscape => write!(f, "Empty escape sequence"), |
82 | InvalidAsciiEscape => write!(f, "Invalid escape sequence"), | 107 | InvalidAsciiEscape => write!(f, "Invalid escape sequence"), |
83 | EmptyChar => write!(f, "Empty char literal"), | 108 | EmptyChar => write!(f, "Empty char literal"), |
84 | UnclosedChar => write!(f, "Unclosed char literal"), | 109 | UnclosedChar => write!(f, "Unclosed char literal"), |
85 | LongChar => write!(f, "Char literal should be one character long"), | 110 | OverlongChar => write!(f, "Char literal should be one character long"), |
111 | EmptyByte => write!(f, "Empty byte literal"), | ||
112 | UnclosedByte => write!(f, "Unclosed byte literal"), | ||
113 | OverlongByte => write!(f, "Byte literal should be one character long"), | ||
114 | ByteOutOfRange => write!(f, "Byte should be a valid ASCII character"), | ||
115 | UnescapedByte => write!(f, "This byte should always be escaped"), | ||
116 | EmptyByteEscape => write!(f, "Empty escape sequence"), | ||
117 | InvalidByteEscape => write!(f, "Invalid escape sequence"), | ||
118 | TooShortByteCodeEscape => write!(f, "Escape sequence should have two digits"), | ||
119 | MalformedByteCodeEscape => write!(f, "Escape sequence should be a hexadecimal number"), | ||
120 | UnicodeEscapeForbidden => write!( | ||
121 | f, | ||
122 | "Unicode escapes are not allowed in byte literals or byte strings" | ||
123 | ), | ||
124 | TooShortAsciiCodeEscape => write!(f, "Escape sequence should have two digits"), | ||
125 | AsciiCodeEscapeOutOfRange => { | ||
126 | write!(f, "Escape sequence should be between \\x00 and \\x7F") | ||
127 | } | ||
128 | MalformedAsciiCodeEscape => write!(f, "Escape sequence should be a hexadecimal number"), | ||
129 | UnclosedUnicodeEscape => write!(f, "Missing `}}`"), | ||
130 | MalformedUnicodeEscape => write!(f, "Malformed unicode escape sequence"), | ||
131 | EmptyUnicodeEcape => write!(f, "Empty unicode escape sequence"), | ||
132 | OverlongUnicodeEscape => { | ||
133 | write!(f, "Unicode escape sequence should have at most 6 digits") | ||
134 | } | ||
135 | UnicodeEscapeOutOfRange => write!(f, "Unicode escape code should be at most 0x10FFFF"), | ||
136 | UnclosedString => write!(f, "Unclosed string literal"), | ||
86 | ParseError(msg) => write!(f, "{}", msg.0), | 137 | ParseError(msg) => write!(f, "{}", msg.0), |
87 | } | 138 | } |
88 | } | 139 | } |