Improves parser diagnostics, fixes #93867
This commit is contained in:
parent
d201c812d4
commit
21fdd549f6
22 changed files with 135 additions and 33 deletions
|
@ -548,6 +548,22 @@ impl<'a> Parser<'a> {
|
|||
is_present
|
||||
}
|
||||
|
||||
fn check_noexpect(&self, tok: &TokenKind) -> bool {
|
||||
self.token == *tok
|
||||
}
|
||||
|
||||
/// Consumes a token 'tok' if it exists. Returns whether the given token was present.
|
||||
///
|
||||
/// the main purpose of this function is to reduce the cluttering of the suggestions list
|
||||
/// which using the normal eat method could introduce in some cases.
|
||||
pub fn eat_noexpect(&mut self, tok: &TokenKind) -> bool {
|
||||
let is_present = self.check_noexpect(tok);
|
||||
if is_present {
|
||||
self.bump()
|
||||
}
|
||||
is_present
|
||||
}
|
||||
|
||||
/// Consumes a token 'tok' if it exists. Returns whether the given token was present.
|
||||
pub fn eat(&mut self, tok: &TokenKind) -> bool {
|
||||
let is_present = self.check(tok);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue