diff options
author | Aleksey Kladov <[email protected]> | 2019-12-19 16:13:08 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-19 16:13:33 +0000 |
commit | 0ed8ce096d3ae9ee4027ab4723958a021ef24194 (patch) | |
tree | 187fb7c2e069cb53682c0ea3b5566854cb17232f /crates/ra_parser/src | |
parent | a766f63650aa08697f68e749d274c2c84d1e3eee (diff) |
Touch up TokenSet a bit
Diffstat (limited to 'crates/ra_parser/src')
-rw-r--r-- | crates/ra_parser/src/grammar.rs | 2 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/expressions/atom.rs | 2 | ||||
-rw-r--r-- | crates/ra_parser/src/parser.rs | 2 | ||||
-rw-r--r-- | crates/ra_parser/src/token_set.rs | 8 |
4 files changed, 6 insertions, 8 deletions
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index 6e9e212b7..22f64a9f4 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs | |||
@@ -264,7 +264,7 @@ fn name_r(p: &mut Parser, recovery: TokenSet) { | |||
264 | } | 264 | } |
265 | 265 | ||
266 | fn name(p: &mut Parser) { | 266 | fn name(p: &mut Parser) { |
267 | name_r(p, TokenSet::empty()) | 267 | name_r(p, TokenSet::EMPTY) |
268 | } | 268 | } |
269 | 269 | ||
270 | fn name_ref(p: &mut Parser) { | 270 | fn name_ref(p: &mut Parser) { |
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index 6f5545a83..4ac1d6334 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs | |||
@@ -444,7 +444,7 @@ fn match_arm(p: &mut Parser) -> BlockLike { | |||
444 | // } | 444 | // } |
445 | attributes::outer_attributes(p); | 445 | attributes::outer_attributes(p); |
446 | 446 | ||
447 | patterns::pattern_list_r(p, TokenSet::empty()); | 447 | patterns::pattern_list_r(p, TokenSet::EMPTY); |
448 | if p.at(T![if]) { | 448 | if p.at(T![if]) { |
449 | match_guard(p); | 449 | match_guard(p); |
450 | } | 450 | } |
diff --git a/crates/ra_parser/src/parser.rs b/crates/ra_parser/src/parser.rs index dafd5247b..1071c46dc 100644 --- a/crates/ra_parser/src/parser.rs +++ b/crates/ra_parser/src/parser.rs | |||
@@ -208,7 +208,7 @@ impl<'t> Parser<'t> { | |||
208 | 208 | ||
209 | /// Create an error node and consume the next token. | 209 | /// Create an error node and consume the next token. |
210 | pub(crate) fn err_and_bump(&mut self, message: &str) { | 210 | pub(crate) fn err_and_bump(&mut self, message: &str) { |
211 | self.err_recover(message, TokenSet::empty()); | 211 | self.err_recover(message, TokenSet::EMPTY); |
212 | } | 212 | } |
213 | 213 | ||
214 | /// Create an error node and consume the next token. | 214 | /// Create an error node and consume the next token. |
diff --git a/crates/ra_parser/src/token_set.rs b/crates/ra_parser/src/token_set.rs index 2a6952c01..994017acf 100644 --- a/crates/ra_parser/src/token_set.rs +++ b/crates/ra_parser/src/token_set.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! A bit-set of `SyntaxKind`s. |
2 | 2 | ||
3 | use crate::SyntaxKind; | 3 | use crate::SyntaxKind; |
4 | 4 | ||
@@ -7,9 +7,7 @@ use crate::SyntaxKind; | |||
7 | pub(crate) struct TokenSet(u128); | 7 | pub(crate) struct TokenSet(u128); |
8 | 8 | ||
9 | impl TokenSet { | 9 | impl TokenSet { |
10 | pub(crate) const fn empty() -> TokenSet { | 10 | pub(crate) const EMPTY: TokenSet = TokenSet(0); |
11 | TokenSet(0) | ||
12 | } | ||
13 | 11 | ||
14 | pub(crate) const fn singleton(kind: SyntaxKind) -> TokenSet { | 12 | pub(crate) const fn singleton(kind: SyntaxKind) -> TokenSet { |
15 | TokenSet(mask(kind)) | 13 | TokenSet(mask(kind)) |
@@ -30,7 +28,7 @@ const fn mask(kind: SyntaxKind) -> u128 { | |||
30 | 28 | ||
31 | #[macro_export] | 29 | #[macro_export] |
32 | macro_rules! token_set { | 30 | macro_rules! token_set { |
33 | ($($t:expr),*) => { TokenSet::empty()$(.union(TokenSet::singleton($t)))* }; | 31 | ($($t:expr),*) => { TokenSet::EMPTY$(.union(TokenSet::singleton($t)))* }; |
34 | ($($t:expr),* ,) => { token_set!($($t),*) }; | 32 | ($($t:expr),* ,) => { token_set!($($t),*) }; |
35 | } | 33 | } |
36 | 34 | ||