diff options
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/lexer.rs | 18 | ||||
-rw-r--r-- | crates/ra_syntax/src/lexer/strings.rs | 3 |
2 files changed, 12 insertions, 9 deletions
diff --git a/crates/ra_syntax/src/lexer.rs b/crates/ra_syntax/src/lexer.rs index c6acd095e..f9362120e 100644 --- a/crates/ra_syntax/src/lexer.rs +++ b/crates/ra_syntax/src/lexer.rs | |||
@@ -190,17 +190,19 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind { | |||
190 | } | 190 | } |
191 | 191 | ||
192 | fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind { | 192 | fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind { |
193 | let is_single_letter = match ptr.current() { | 193 | let is_raw = match (c, ptr.current()) { |
194 | None => true, | 194 | ('r', Some('#')) => { |
195 | Some(c) if !is_ident_continue(c) => true, | 195 | ptr.bump(); |
196 | true | ||
197 | } | ||
198 | ('_', Some(c)) if !is_ident_continue(c) => return UNDERSCORE, | ||
196 | _ => false, | 199 | _ => false, |
197 | }; | 200 | }; |
198 | if is_single_letter { | ||
199 | return if c == '_' { UNDERSCORE } else { IDENT }; | ||
200 | } | ||
201 | ptr.bump_while(is_ident_continue); | 201 | ptr.bump_while(is_ident_continue); |
202 | if let Some(kind) = SyntaxKind::from_keyword(ptr.current_token_text()) { | 202 | if !is_raw { |
203 | return kind; | 203 | if let Some(kind) = SyntaxKind::from_keyword(ptr.current_token_text()) { |
204 | return kind; | ||
205 | } | ||
204 | } | 206 | } |
205 | IDENT | 207 | IDENT |
206 | } | 208 | } |
diff --git a/crates/ra_syntax/src/lexer/strings.rs b/crates/ra_syntax/src/lexer/strings.rs index 0865b7f3b..5c1cf3e9c 100644 --- a/crates/ra_syntax/src/lexer/strings.rs +++ b/crates/ra_syntax/src/lexer/strings.rs | |||
@@ -5,7 +5,8 @@ use crate::lexer::ptr::Ptr; | |||
5 | pub(crate) fn is_string_literal_start(c: char, c1: Option<char>, c2: Option<char>) -> bool { | 5 | pub(crate) fn is_string_literal_start(c: char, c1: Option<char>, c2: Option<char>) -> bool { |
6 | match (c, c1, c2) { | 6 | match (c, c1, c2) { |
7 | ('r', Some('"'), _) | 7 | ('r', Some('"'), _) |
8 | | ('r', Some('#'), _) | 8 | | ('r', Some('#'), Some('"')) |
9 | | ('r', Some('#'), Some('#')) | ||
9 | | ('b', Some('"'), _) | 10 | | ('b', Some('"'), _) |
10 | | ('b', Some('\''), _) | 11 | | ('b', Some('\''), _) |
11 | | ('b', Some('r'), Some('"')) | 12 | | ('b', Some('r'), Some('"')) |