add block matcher

This commit is contained in:
Edwin Cheng 2019-04-19 19:33:29 +08:00
parent 8092b6487f
commit 762819864f
6 changed files with 64 additions and 0 deletions

View file

@ -99,6 +99,33 @@ pub(crate) fn block(p: &mut Parser) {
expressions::block(p);
}
// Parse a meta item , which excluded [], e.g : #[ MetaItem ]
pub(crate) fn meta_item(p: &mut Parser) {
fn is_delimiter(p: &mut Parser) -> bool {
match p.current() {
L_CURLY | L_PAREN | L_BRACK => true,
_ => false,
}
}
if is_delimiter(p) {
items::token_tree(p);
return;
}
let m = p.start();
while !p.at(EOF) {
if is_delimiter(p) {
items::token_tree(p);
break;
} else {
p.bump();
}
}
m.complete(p, TOKEN_TREE);
}
pub(crate) fn item(p: &mut Parser) {
items::item_or_macro(p, true, items::ItemFlavor::Mod)
}