diff options
Diffstat (limited to 'crates/ra_syntax/src/parsing')
-rw-r--r-- | crates/ra_syntax/src/parsing/lexer.rs | 25 | ||||
-rw-r--r-- | crates/ra_syntax/src/parsing/reparsing.rs | 11 |
2 files changed, 19 insertions, 17 deletions
diff --git a/crates/ra_syntax/src/parsing/lexer.rs b/crates/ra_syntax/src/parsing/lexer.rs index a3791b503..6eb96f03d 100644 --- a/crates/ra_syntax/src/parsing/lexer.rs +++ b/crates/ra_syntax/src/parsing/lexer.rs | |||
@@ -7,6 +7,7 @@ mod strings; | |||
7 | use crate::{ | 7 | use crate::{ |
8 | SyntaxKind::{self, *}, | 8 | SyntaxKind::{self, *}, |
9 | TextUnit, | 9 | TextUnit, |
10 | T, | ||
10 | }; | 11 | }; |
11 | 12 | ||
12 | use self::{ | 13 | use self::{ |
@@ -90,16 +91,16 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind { | |||
90 | match c { | 91 | match c { |
91 | // Possiblily multi-byte tokens, | 92 | // Possiblily multi-byte tokens, |
92 | // but we only produce single byte token now | 93 | // but we only produce single byte token now |
93 | // DOTDOTDOT, DOTDOT, DOTDOTEQ, DOT | 94 | // T![...], T![..], T![..=], T![.] |
94 | '.' => return DOT, | 95 | '.' => return T![.], |
95 | // COLONCOLON COLON | 96 | // T![::] T![:] |
96 | ':' => return COLON, | 97 | ':' => return T![:], |
97 | // EQEQ FATARROW EQ | 98 | // T![==] FATARROW T![=] |
98 | '=' => return EQ, | 99 | '=' => return T![=], |
99 | // NEQ EXCL | 100 | // T![!=] T![!] |
100 | '!' => return EXCL, | 101 | '!' => return T![!], |
101 | // THIN_ARROW MINUS | 102 | // T![->] T![-] |
102 | '-' => return MINUS, | 103 | '-' => return T![-], |
103 | 104 | ||
104 | // If the character is an ident start not followed by another single | 105 | // If the character is an ident start not followed by another single |
105 | // quote, then this is a lifetime name: | 106 | // quote, then this is a lifetime name: |
@@ -148,8 +149,8 @@ fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind { | |||
148 | ptr.bump(); | 149 | ptr.bump(); |
149 | true | 150 | true |
150 | } | 151 | } |
151 | ('_', None) => return UNDERSCORE, | 152 | ('_', None) => return T![_], |
152 | ('_', Some(c)) if !is_ident_continue(c) => return UNDERSCORE, | 153 | ('_', Some(c)) if !is_ident_continue(c) => return T![_], |
153 | _ => false, | 154 | _ => false, |
154 | }; | 155 | }; |
155 | ptr.bump_while(is_ident_continue); | 156 | ptr.bump_while(is_ident_continue); |
diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs index 434f850d1..6de02a15a 100644 --- a/crates/ra_syntax/src/parsing/reparsing.rs +++ b/crates/ra_syntax/src/parsing/reparsing.rs | |||
@@ -17,7 +17,8 @@ use crate::{ | |||
17 | text_token_source::TextTokenSource, | 17 | text_token_source::TextTokenSource, |
18 | text_tree_sink::TextTreeSink, | 18 | text_tree_sink::TextTreeSink, |
19 | lexer::{tokenize, Token}, | 19 | lexer::{tokenize, Token}, |
20 | } | 20 | }, |
21 | T, | ||
21 | }; | 22 | }; |
22 | 23 | ||
23 | pub(crate) fn incremental_reparse( | 24 | pub(crate) fn incremental_reparse( |
@@ -122,16 +123,16 @@ fn find_reparsable_node(node: &SyntaxNode, range: TextRange) -> Option<(&SyntaxN | |||
122 | 123 | ||
123 | fn is_balanced(tokens: &[Token]) -> bool { | 124 | fn is_balanced(tokens: &[Token]) -> bool { |
124 | if tokens.is_empty() | 125 | if tokens.is_empty() |
125 | || tokens.first().unwrap().kind != L_CURLY | 126 | || tokens.first().unwrap().kind != T!['{'] |
126 | || tokens.last().unwrap().kind != R_CURLY | 127 | || tokens.last().unwrap().kind != T!['}'] |
127 | { | 128 | { |
128 | return false; | 129 | return false; |
129 | } | 130 | } |
130 | let mut balance = 0usize; | 131 | let mut balance = 0usize; |
131 | for t in &tokens[1..tokens.len() - 1] { | 132 | for t in &tokens[1..tokens.len() - 1] { |
132 | match t.kind { | 133 | match t.kind { |
133 | L_CURLY => balance += 1, | 134 | T!['{'] => balance += 1, |
134 | R_CURLY => { | 135 | T!['}'] => { |
135 | balance = match balance.checked_sub(1) { | 136 | balance = match balance.checked_sub(1) { |
136 | Some(b) => b, | 137 | Some(b) => b, |
137 | None => return false, | 138 | None => return false, |