Implement ignore and index metavar expression

This commit is contained in:
Jonas Schievink 2022-07-11 18:31:42 +02:00
parent f7bb9327ad
commit df66eb74ab
7 changed files with 108 additions and 5 deletions

View file

@ -73,6 +73,13 @@ impl<'a> TtIter<'a> {
}
}
pub(crate) fn expect_u32_literal(&mut self) -> Result<u32, ()> {
match self.expect_literal()? {
tt::Leaf::Literal(lit) => lit.text.parse().map_err(drop),
_ => Err(()),
}
}
pub(crate) fn expect_punct(&mut self) -> Result<&'a tt::Punct, ()> {
match self.expect_leaf()? {
tt::Leaf::Punct(it) => Ok(it),