diff options
author | Veetaha <[email protected]> | 2020-01-26 18:44:49 +0000 |
---|---|---|
committer | Veetaha <[email protected]> | 2020-02-03 22:00:55 +0000 |
commit | ac37a11f04b31f792068a1cb50dbbf5ccd4d982d (patch) | |
tree | 52542f3e7b7ec9f4cfbedf2245c4fd4bb8cdffcb /crates/ra_mbe/src | |
parent | ad24976da38482948c586bdbc16004273662ff7e (diff) |
Reimplemented lexer with vectors instead of iterators
Diffstat (limited to 'crates/ra_mbe/src')
-rw-r--r-- | crates/ra_mbe/src/subtree_source.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/ra_mbe/src/subtree_source.rs index b841c39d3..72ac8df03 100644 --- a/crates/ra_mbe/src/subtree_source.rs +++ b/crates/ra_mbe/src/subtree_source.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use ra_parser::{Token, TokenSource}; | 3 | use ra_parser::{Token, TokenSource}; |
4 | use ra_syntax::{classify_literal, SmolStr, SyntaxKind, SyntaxKind::*, T}; | 4 | use ra_syntax::{single_token, SmolStr, SyntaxKind, SyntaxKind::*, T}; |
5 | use std::cell::{Cell, Ref, RefCell}; | 5 | use std::cell::{Cell, Ref, RefCell}; |
6 | use tt::buffer::{Cursor, TokenBuffer}; | 6 | use tt::buffer::{Cursor, TokenBuffer}; |
7 | 7 | ||
@@ -129,8 +129,10 @@ fn convert_delim(d: Option<tt::DelimiterKind>, closing: bool) -> TtToken { | |||
129 | } | 129 | } |
130 | 130 | ||
131 | fn convert_literal(l: &tt::Literal) -> TtToken { | 131 | fn convert_literal(l: &tt::Literal) -> TtToken { |
132 | let kind = | 132 | let kind = single_token(&l.text) |
133 | classify_literal(&l.text).map(|tkn| tkn.kind).unwrap_or_else(|| match l.text.as_ref() { | 133 | .map(|parsed| parsed.token.kind) |
134 | .filter(|kind| kind.is_literal()) | ||
135 | .unwrap_or_else(|| match l.text.as_ref() { | ||
134 | "true" => T![true], | 136 | "true" => T![true], |
135 | "false" => T![false], | 137 | "false" => T![false], |
136 | _ => panic!("Fail to convert given literal {:#?}", &l), | 138 | _ => panic!("Fail to convert given literal {:#?}", &l), |