diff options
Diffstat (limited to 'crates/ra_syntax/src/parsing')
-rw-r--r-- | crates/ra_syntax/src/parsing/lexer.rs | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/crates/ra_syntax/src/parsing/lexer.rs b/crates/ra_syntax/src/parsing/lexer.rs index d1baaa607..67c1f1b48 100644 --- a/crates/ra_syntax/src/parsing/lexer.rs +++ b/crates/ra_syntax/src/parsing/lexer.rs | |||
@@ -4,7 +4,7 @@ | |||
4 | use crate::{ | 4 | use crate::{ |
5 | SyntaxError, | 5 | SyntaxError, |
6 | SyntaxKind::{self, *}, | 6 | SyntaxKind::{self, *}, |
7 | TextRange, TextUnit, | 7 | TextRange, TextUnit, T, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | /// A token of Rust source. | 10 | /// A token of Rust source. |
@@ -115,21 +115,20 @@ fn rustc_token_kind_to_syntax_kind( | |||
115 | // being `u16` that come from `rowan::SyntaxKind`. | 115 | // being `u16` that come from `rowan::SyntaxKind`. |
116 | 116 | ||
117 | let syntax_kind = { | 117 | let syntax_kind = { |
118 | use rustc_lexer::TokenKind as TK; | ||
119 | match rustc_token_kind { | 118 | match rustc_token_kind { |
120 | TK::LineComment => COMMENT, | 119 | rustc_lexer::TokenKind::LineComment => COMMENT, |
121 | 120 | ||
122 | TK::BlockComment { terminated: true } => COMMENT, | 121 | rustc_lexer::TokenKind::BlockComment { terminated: true } => COMMENT, |
123 | TK::BlockComment { terminated: false } => { | 122 | rustc_lexer::TokenKind::BlockComment { terminated: false } => { |
124 | return ( | 123 | return ( |
125 | COMMENT, | 124 | COMMENT, |
126 | Some("Missing trailing `*/` symbols to terminate the block comment"), | 125 | Some("Missing trailing `*/` symbols to terminate the block comment"), |
127 | ); | 126 | ); |
128 | } | 127 | } |
129 | 128 | ||
130 | TK::Whitespace => WHITESPACE, | 129 | rustc_lexer::TokenKind::Whitespace => WHITESPACE, |
131 | 130 | ||
132 | TK::Ident => { | 131 | rustc_lexer::TokenKind::Ident => { |
133 | if token_text == "_" { | 132 | if token_text == "_" { |
134 | UNDERSCORE | 133 | UNDERSCORE |
135 | } else { | 134 | } else { |
@@ -137,42 +136,42 @@ fn rustc_token_kind_to_syntax_kind( | |||
137 | } | 136 | } |
138 | } | 137 | } |
139 | 138 | ||
140 | TK::RawIdent => IDENT, | 139 | rustc_lexer::TokenKind::RawIdent => IDENT, |
141 | TK::Literal { kind, .. } => return match_literal_kind(&kind), | 140 | rustc_lexer::TokenKind::Literal { kind, .. } => return match_literal_kind(&kind), |
142 | 141 | ||
143 | TK::Lifetime { starts_with_number: false } => LIFETIME, | 142 | rustc_lexer::TokenKind::Lifetime { starts_with_number: false } => LIFETIME, |
144 | TK::Lifetime { starts_with_number: true } => { | 143 | rustc_lexer::TokenKind::Lifetime { starts_with_number: true } => { |
145 | return (LIFETIME, Some("Lifetime name cannot start with a number")) | 144 | return (LIFETIME, Some("Lifetime name cannot start with a number")) |
146 | } | 145 | } |
147 | 146 | ||
148 | TK::Semi => SEMI, | 147 | rustc_lexer::TokenKind::Semi => T![;], |
149 | TK::Comma => COMMA, | 148 | rustc_lexer::TokenKind::Comma => T![,], |
150 | TK::Dot => DOT, | 149 | rustc_lexer::TokenKind::Dot => T![.], |
151 | TK::OpenParen => L_PAREN, | 150 | rustc_lexer::TokenKind::OpenParen => T!['('], |
152 | TK::CloseParen => R_PAREN, | 151 | rustc_lexer::TokenKind::CloseParen => T![')'], |
153 | TK::OpenBrace => L_CURLY, | 152 | rustc_lexer::TokenKind::OpenBrace => T!['{'], |
154 | TK::CloseBrace => R_CURLY, | 153 | rustc_lexer::TokenKind::CloseBrace => T!['}'], |
155 | TK::OpenBracket => L_BRACK, | 154 | rustc_lexer::TokenKind::OpenBracket => T!['['], |
156 | TK::CloseBracket => R_BRACK, | 155 | rustc_lexer::TokenKind::CloseBracket => T![']'], |
157 | TK::At => AT, | 156 | rustc_lexer::TokenKind::At => T![@], |
158 | TK::Pound => POUND, | 157 | rustc_lexer::TokenKind::Pound => T![#], |
159 | TK::Tilde => TILDE, | 158 | rustc_lexer::TokenKind::Tilde => T![~], |
160 | TK::Question => QUESTION, | 159 | rustc_lexer::TokenKind::Question => T![?], |
161 | TK::Colon => COLON, | 160 | rustc_lexer::TokenKind::Colon => T![:], |
162 | TK::Dollar => DOLLAR, | 161 | rustc_lexer::TokenKind::Dollar => T![$], |
163 | TK::Eq => EQ, | 162 | rustc_lexer::TokenKind::Eq => T![=], |
164 | TK::Not => EXCL, | 163 | rustc_lexer::TokenKind::Not => T![!], |
165 | TK::Lt => L_ANGLE, | 164 | rustc_lexer::TokenKind::Lt => T![<], |
166 | TK::Gt => R_ANGLE, | 165 | rustc_lexer::TokenKind::Gt => T![>], |
167 | TK::Minus => MINUS, | 166 | rustc_lexer::TokenKind::Minus => T![-], |
168 | TK::And => AMP, | 167 | rustc_lexer::TokenKind::And => T![&], |
169 | TK::Or => PIPE, | 168 | rustc_lexer::TokenKind::Or => T![|], |
170 | TK::Plus => PLUS, | 169 | rustc_lexer::TokenKind::Plus => T![+], |
171 | TK::Star => STAR, | 170 | rustc_lexer::TokenKind::Star => T![*], |
172 | TK::Slash => SLASH, | 171 | rustc_lexer::TokenKind::Slash => T![/], |
173 | TK::Caret => CARET, | 172 | rustc_lexer::TokenKind::Caret => T![^], |
174 | TK::Percent => PERCENT, | 173 | rustc_lexer::TokenKind::Percent => T![%], |
175 | TK::Unknown => ERROR, | 174 | rustc_lexer::TokenKind::Unknown => ERROR, |
176 | } | 175 | } |
177 | }; | 176 | }; |
178 | 177 | ||