diff options
author | Edwin Cheng <[email protected]> | 2019-04-05 11:45:19 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-04-05 11:45:19 +0100 |
commit | 1ea0238e538dc332b23698d54c02d8bd037f58bb (patch) | |
tree | 824ba6536a7f6f5ba9d8211b81dcb8dbce5c6854 /crates/ra_syntax/src/parsing | |
parent | 1ab78d60561ed701b29d3065061cbc3175e20c4a (diff) |
Add classify_literal and undo expose next_token
Diffstat (limited to 'crates/ra_syntax/src/parsing')
-rw-r--r-- | crates/ra_syntax/src/parsing/lexer.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/parsing/lexer.rs b/crates/ra_syntax/src/parsing/lexer.rs index 36e841609..e75f3aae0 100644 --- a/crates/ra_syntax/src/parsing/lexer.rs +++ b/crates/ra_syntax/src/parsing/lexer.rs | |||
@@ -214,3 +214,12 @@ fn scan_literal_suffix(ptr: &mut Ptr) { | |||
214 | } | 214 | } |
215 | ptr.bump_while(is_ident_continue); | 215 | ptr.bump_while(is_ident_continue); |
216 | } | 216 | } |
217 | |||
218 | pub fn classify_literal(text: &str) -> Option<Token> { | ||
219 | let tkn = next_token(text); | ||
220 | if tkn.kind.is_literal() || tkn.len.to_usize() != text.len() { | ||
221 | return None; | ||
222 | } | ||
223 | |||
224 | Some(tkn) | ||
225 | } | ||