Skip to content

Commit afa1883

Browse files
committed
add expect_keywords function
1 parent 0e68cee commit afa1883

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/parser.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,15 @@ impl Parser {
816816
}
817817
}
818818

819+
/// Bail out if the following tokens are not the excpected sequence of keywords,
820+
/// or consume them if they are
821+
pub fn expect_keywords(&mut self, expected: &[&'static str]) -> Result<(), ParserError> {
822+
for kw in expected {
823+
self.expect_keyword(kw)?;
824+
}
825+
Ok(())
826+
}
827+
819828
/// Consume the next token if it matches the expected token, otherwise return false
820829
#[must_use]
821830
pub fn consume_token(&mut self, expected: &Token) -> bool {

0 commit comments

Comments
 (0)