aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-23 18:30:00 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-23 18:30:00 +0000
commit302508d5bbcc261f8fe403714a7a7e1f5382879b (patch)
tree72b32afb919c5317219c0891ced8c9725d622bbc /crates/ra_syntax/src
parent0b942cbcb071811a811aa35feaa80950c2415075 (diff)
parent3b70acad0106e4ffe5ee68d565c9130b5b271e22 (diff)
Merge #616
616: Lex raw idents correctly r=matklad a=jrobsonchase One question: What's the intent of the text by the `IDENT` node under `NAME`? Should it be the actual token text or the semantic name? Closes #611 Co-authored-by: Josh Robson Chase <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/lexer.rs13
-rw-r--r--crates/ra_syntax/src/lexer/strings.rs3
2 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_syntax/src/lexer.rs b/crates/ra_syntax/src/lexer.rs
index c6acd095e..0c3847120 100644
--- a/crates/ra_syntax/src/lexer.rs
+++ b/crates/ra_syntax/src/lexer.rs
@@ -190,13 +190,12 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind {
190} 190}
191 191
192fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind { 192fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind {
193 let is_single_letter = match ptr.current() { 193 match (c, ptr.current()) {
194 None => true, 194 ('r', Some('#')) => {
195 Some(c) if !is_ident_continue(c) => true, 195 ptr.bump();
196 _ => false, 196 }
197 }; 197 ('_', Some(c)) if !is_ident_continue(c) => return UNDERSCORE,
198 if is_single_letter { 198 _ => {}
199 return if c == '_' { UNDERSCORE } else { IDENT };
200 } 199 }
201 ptr.bump_while(is_ident_continue); 200 ptr.bump_while(is_ident_continue);
202 if let Some(kind) = SyntaxKind::from_keyword(ptr.current_token_text()) { 201 if let Some(kind) = SyntaxKind::from_keyword(ptr.current_token_text()) {
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;
5pub(crate) fn is_string_literal_start(c: char, c1: Option<char>, c2: Option<char>) -> bool { 5pub(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('"'))