Generalize blocklike
This commit is contained in:
parent
42e3a8ef77
commit
0ab1e255ee
2 changed files with 13 additions and 12 deletions
|
|
@ -27,8 +27,8 @@ pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) {
|
|||
MaybeItem::None => {
|
||||
if paths::is_path_start(p) {
|
||||
match macro_call(p) {
|
||||
MacroFlavor::Curly => (),
|
||||
MacroFlavor::NonCurly => {
|
||||
BlockLike::Block => (),
|
||||
BlockLike::NotBlock => {
|
||||
p.expect(SEMI);
|
||||
}
|
||||
}
|
||||
|
|
@ -277,32 +277,27 @@ fn mod_item(p: &mut Parser) {
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) enum MacroFlavor {
|
||||
Curly,
|
||||
NonCurly,
|
||||
}
|
||||
|
||||
fn macro_call(p: &mut Parser) -> MacroFlavor {
|
||||
fn macro_call(p: &mut Parser) -> BlockLike {
|
||||
assert!(paths::is_path_start(p));
|
||||
paths::use_path(p);
|
||||
macro_call_after_excl(p)
|
||||
}
|
||||
|
||||
pub(super) fn macro_call_after_excl(p: &mut Parser) -> MacroFlavor {
|
||||
pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike {
|
||||
p.expect(EXCL);
|
||||
p.eat(IDENT);
|
||||
let flavor = match p.current() {
|
||||
L_CURLY => {
|
||||
token_tree(p);
|
||||
MacroFlavor::Curly
|
||||
BlockLike::Block
|
||||
}
|
||||
L_PAREN | L_BRACK => {
|
||||
token_tree(p);
|
||||
MacroFlavor::NonCurly
|
||||
BlockLike::NotBlock
|
||||
}
|
||||
_ => {
|
||||
p.error("expected `{`, `[`, `(`");
|
||||
MacroFlavor::NonCurly
|
||||
BlockLike::NotBlock
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,12 @@ pub(crate) fn file(p: &mut Parser) {
|
|||
file.complete(p, FILE);
|
||||
}
|
||||
|
||||
|
||||
enum BlockLike {
|
||||
Block,
|
||||
NotBlock,
|
||||
}
|
||||
|
||||
fn visibility(p: &mut Parser) {
|
||||
if p.at(PUB_KW) {
|
||||
let vis = p.start();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue