diff options
author | Evgenii P <[email protected]> | 2019-08-09 09:04:13 +0100 |
---|---|---|
committer | Evgenii P <[email protected]> | 2019-08-09 09:04:13 +0100 |
commit | db4839033c1903f0926100692b69641b506c05d1 (patch) | |
tree | 2e6e19db015cc7d9b49434da5b040371cc00d734 /crates | |
parent | 073cf423916c8854e060a1127856dc4736fe83b1 (diff) |
Change macro to function
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_syntax/src/parsing/lexer.rs | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/crates/ra_syntax/src/parsing/lexer.rs b/crates/ra_syntax/src/parsing/lexer.rs index 7a9bc355d..06822ea91 100644 --- a/crates/ra_syntax/src/parsing/lexer.rs +++ b/crates/ra_syntax/src/parsing/lexer.rs | |||
@@ -12,19 +12,17 @@ pub struct Token { | |||
12 | pub len: TextUnit, | 12 | pub len: TextUnit, |
13 | } | 13 | } |
14 | 14 | ||
15 | macro_rules! match_literal_kind { | 15 | fn match_literal_kind(kind: ra_rustc_lexer::LiteralKind) -> SyntaxKind { |
16 | ($kind:expr) => { | 16 | match kind { |
17 | match $kind { | 17 | ra_rustc_lexer::LiteralKind::Int { .. } => INT_NUMBER, |
18 | ra_rustc_lexer::LiteralKind::Int { .. } => INT_NUMBER, | 18 | ra_rustc_lexer::LiteralKind::Float { .. } => FLOAT_NUMBER, |
19 | ra_rustc_lexer::LiteralKind::Float { .. } => FLOAT_NUMBER, | 19 | ra_rustc_lexer::LiteralKind::Char { .. } => CHAR, |
20 | ra_rustc_lexer::LiteralKind::Char { .. } => CHAR, | 20 | ra_rustc_lexer::LiteralKind::Byte { .. } => BYTE, |
21 | ra_rustc_lexer::LiteralKind::Byte { .. } => BYTE, | 21 | ra_rustc_lexer::LiteralKind::Str { .. } => STRING, |
22 | ra_rustc_lexer::LiteralKind::Str { .. } => STRING, | 22 | ra_rustc_lexer::LiteralKind::ByteStr { .. } => BYTE_STRING, |
23 | ra_rustc_lexer::LiteralKind::ByteStr { .. } => BYTE_STRING, | 23 | ra_rustc_lexer::LiteralKind::RawStr { .. } => RAW_STRING, |
24 | ra_rustc_lexer::LiteralKind::RawStr { .. } => RAW_STRING, | 24 | ra_rustc_lexer::LiteralKind::RawByteStr { .. } => RAW_BYTE_STRING, |
25 | ra_rustc_lexer::LiteralKind::RawByteStr { .. } => RAW_BYTE_STRING, | 25 | } |
26 | } | ||
27 | }; | ||
28 | } | 26 | } |
29 | 27 | ||
30 | /// Break a string up into its component tokens | 28 | /// Break a string up into its component tokens |
@@ -68,7 +66,7 @@ pub fn tokenize(text: &str) -> Vec<Token> { | |||
68 | } | 66 | } |
69 | } | 67 | } |
70 | ra_rustc_lexer::TokenKind::RawIdent => IDENT, | 68 | ra_rustc_lexer::TokenKind::RawIdent => IDENT, |
71 | ra_rustc_lexer::TokenKind::Literal { kind, .. } => match_literal_kind!(kind), | 69 | ra_rustc_lexer::TokenKind::Literal { kind, .. } => match_literal_kind(kind), |
72 | ra_rustc_lexer::TokenKind::Lifetime { .. } => LIFETIME, | 70 | ra_rustc_lexer::TokenKind::Lifetime { .. } => LIFETIME, |
73 | ra_rustc_lexer::TokenKind::Semi => SEMI, | 71 | ra_rustc_lexer::TokenKind::Semi => SEMI, |
74 | ra_rustc_lexer::TokenKind::Comma => COMMA, | 72 | ra_rustc_lexer::TokenKind::Comma => COMMA, |
@@ -137,7 +135,7 @@ pub fn classify_literal(text: &str) -> Option<Token> { | |||
137 | return None; | 135 | return None; |
138 | } | 136 | } |
139 | let kind = match t.kind { | 137 | let kind = match t.kind { |
140 | ra_rustc_lexer::TokenKind::Literal { kind, .. } => match_literal_kind!(kind), | 138 | ra_rustc_lexer::TokenKind::Literal { kind, .. } => match_literal_kind(kind), |
141 | _ => return None, | 139 | _ => return None, |
142 | }; | 140 | }; |
143 | Some(Token { kind, len: TextUnit::from_usize(t.len) }) | 141 | Some(Token { kind, len: TextUnit::from_usize(t.len) }) |