diff options
author | Aleksey Kladov <[email protected]> | 2019-09-09 23:03:00 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-09-09 23:03:00 +0100 |
commit | d8aa9a1d81529cdc39e8353f2915c3c4d04ac263 (patch) | |
tree | e0c25226d8a13b3ff2a13d1100315e8455ea98bd /crates/ra_parser/src/parser.rs | |
parent | e2b378ef7e0ed82b0f0c874f98032a368fd5f30f (diff) |
introduce bump as a better-checked alternative to bump_any
Diffstat (limited to 'crates/ra_parser/src/parser.rs')
-rw-r--r-- | crates/ra_parser/src/parser.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/crates/ra_parser/src/parser.rs b/crates/ra_parser/src/parser.rs index ccacaacad..d8567e84b 100644 --- a/crates/ra_parser/src/parser.rs +++ b/crates/ra_parser/src/parser.rs | |||
@@ -170,6 +170,12 @@ impl<'t> Parser<'t> { | |||
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | /// Advances the parser by one token, asserting that it is exactly the expected token | ||
174 | pub(crate) fn bump(&mut self, expected: SyntaxKind) { | ||
175 | debug_assert!(self.nth(0) == expected); | ||
176 | self.bump_any() | ||
177 | } | ||
178 | |||
173 | /// Advances the parser by one token, remapping its kind. | 179 | /// Advances the parser by one token, remapping its kind. |
174 | /// This is useful to create contextual keywords from | 180 | /// This is useful to create contextual keywords from |
175 | /// identifiers. For example, the lexer creates an `union` | 181 | /// identifiers. For example, the lexer creates an `union` |