aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/yellow/syntax_error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/yellow/syntax_error.rs')
-rw-r--r--crates/ra_syntax/src/yellow/syntax_error.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/yellow/syntax_error.rs b/crates/ra_syntax/src/yellow/syntax_error.rs
index f3df6bc15..c524adf39 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,20 @@ impl fmt::Display for SyntaxError {
64#[derive(Debug, Clone, PartialEq, Eq, Hash)] 68#[derive(Debug, Clone, PartialEq, Eq, Hash)]
65pub enum SyntaxErrorKind { 69pub enum SyntaxErrorKind {
66 ParseError(ParseError), 70 ParseError(ParseError),
71 UnescapedCodepoint,
67 EmptyChar, 72 EmptyChar,
68 UnclosedChar, 73 UnclosedChar,
69 LongChar, 74 LongChar,
70 EmptyAsciiEscape, 75 EmptyAsciiEscape,
71 InvalidAsciiEscape, 76 InvalidAsciiEscape,
77 TooShortAsciiCodeEscape,
78 AsciiCodeEscapeOutOfRange,
79 MalformedAsciiCodeEscape,
80 UnclosedUnicodeEscape,
81 MalformedUnicodeEscape,
82 EmptyUnicodeEcape,
83 OverlongUnicodeEscape,
84 UnicodeEscapeOutOfRange,
72} 85}
73 86
74#[derive(Debug, Clone, PartialEq, Eq, Hash)] 87#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -78,11 +91,24 @@ impl fmt::Display for SyntaxErrorKind {
78 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 91 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
79 use self::SyntaxErrorKind::*; 92 use self::SyntaxErrorKind::*;
80 match self { 93 match self {
94 UnescapedCodepoint => write!(f, "This codepoint should always be escaped"),
81 EmptyAsciiEscape => write!(f, "Empty escape sequence"), 95 EmptyAsciiEscape => write!(f, "Empty escape sequence"),
82 InvalidAsciiEscape => write!(f, "Invalid escape sequence"), 96 InvalidAsciiEscape => write!(f, "Invalid escape sequence"),
83 EmptyChar => write!(f, "Empty char literal"), 97 EmptyChar => write!(f, "Empty char literal"),
84 UnclosedChar => write!(f, "Unclosed char literal"), 98 UnclosedChar => write!(f, "Unclosed char literal"),
85 LongChar => write!(f, "Char literal should be one character long"), 99 LongChar => write!(f, "Char literal should be one character long"),
100 TooShortAsciiCodeEscape => write!(f, "Escape sequence should have two digits"),
101 AsciiCodeEscapeOutOfRange => {
102 write!(f, "Escape sequence should be between \\x00 and \\x7F")
103 }
104 MalformedAsciiCodeEscape => write!(f, "Escape sequence should be a hexadecimal number"),
105 UnclosedUnicodeEscape => write!(f, "Missing `}}`"),
106 MalformedUnicodeEscape => write!(f, "Malformed unicode escape sequence"),
107 EmptyUnicodeEcape => write!(f, "Empty unicode escape sequence"),
108 OverlongUnicodeEscape => {
109 write!(f, "Unicode escape sequence should have at most 6 digits")
110 }
111 UnicodeEscapeOutOfRange => write!(f, "Unicode escape code should be at most 0x10FFFF"),
86 ParseError(msg) => write!(f, "{}", msg.0), 112 ParseError(msg) => write!(f, "{}", msg.0),
87 } 113 }
88 } 114 }