Skip to content

Commit df298b4

Browse files
committed
syntax: document some methods.
1 parent 151ce96 commit df298b4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,13 +511,15 @@ impl<'a> Parser<'a> {
511511
is_present
512512
}
513513

514+
/// If the next token is the given keyword, returns `true` without eating it.
515+
/// An expectation is also added for diagnostics purposes.
514516
fn check_keyword(&mut self, kw: Symbol) -> bool {
515517
self.expected_tokens.push(TokenType::Keyword(kw));
516518
self.token.is_keyword(kw)
517519
}
518520

519-
/// If the next token is the given keyword, eats it and returns
520-
/// `true`. Otherwise, returns `false`.
521+
/// If the next token is the given keyword, eats it and returns `true`.
522+
/// Otherwise, returns `false`. An expectation is also added for diagnostics purposes.
521523
pub fn eat_keyword(&mut self, kw: Symbol) -> bool {
522524
if self.check_keyword(kw) {
523525
self.bump();
@@ -896,6 +898,8 @@ impl<'a> Parser<'a> {
896898
self.expected_tokens.clear();
897899
}
898900

901+
/// Look-ahead `dist` tokens of `self.token` and get access to that token there.
902+
/// When `dist == 0` then the current token is looked at.
899903
pub fn look_ahead<R>(&self, dist: usize, looker: impl FnOnce(&Token) -> R) -> R {
900904
if dist == 0 {
901905
return looker(&self.token);

0 commit comments

Comments
 (0)