diff options
author | Josh Robson Chase <[email protected]> | 2019-01-23 17:15:47 +0000 |
---|---|---|
committer | Josh Robson Chase <[email protected]> | 2019-01-23 18:17:41 +0000 |
commit | 1cd6d6539a9d85bc44db364bb9165e6d9253790d (patch) | |
tree | 9700b48ecbf34496d45c5e08e27c113698fb1452 /crates/ra_syntax/src/lexer.rs | |
parent | 0b942cbcb071811a811aa35feaa80950c2415075 (diff) |
Add raw idents to lexer and parser
Diffstat (limited to 'crates/ra_syntax/src/lexer.rs')
-rw-r--r-- | crates/ra_syntax/src/lexer.rs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/crates/ra_syntax/src/lexer.rs b/crates/ra_syntax/src/lexer.rs index c6acd095e..fab184a2d 100644 --- a/crates/ra_syntax/src/lexer.rs +++ b/crates/ra_syntax/src/lexer.rs | |||
@@ -190,19 +190,24 @@ 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 { | 201 | |
199 | return if c == '_' { UNDERSCORE } else { IDENT }; | ||
200 | } | ||
201 | ptr.bump_while(is_ident_continue); | 202 | ptr.bump_while(is_ident_continue); |
202 | if let Some(kind) = SyntaxKind::from_keyword(ptr.current_token_text()) { | 203 | |
204 | if is_raw { | ||
205 | RAW_IDENT | ||
206 | } else if let Some(kind) = SyntaxKind::from_keyword(ptr.current_token_text()) { | ||
203 | return kind; | 207 | return kind; |
208 | } else { | ||
209 | IDENT | ||
204 | } | 210 | } |
205 | IDENT | ||
206 | } | 211 | } |
207 | 212 | ||
208 | fn scan_literal_suffix(ptr: &mut Ptr) { | 213 | fn scan_literal_suffix(ptr: &mut Ptr) { |