aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/grammar/items/mod.rs19
-rw-r--r--src/grammar/mod.rs6
2 files changed, 13 insertions, 12 deletions
diff --git a/src/grammar/items/mod.rs b/src/grammar/items/mod.rs
index 657078765..83f1833b5 100644
--- a/src/grammar/items/mod.rs
+++ b/src/grammar/items/mod.rs
@@ -27,8 +27,8 @@ pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) {
27 MaybeItem::None => { 27 MaybeItem::None => {
28 if paths::is_path_start(p) { 28 if paths::is_path_start(p) {
29 match macro_call(p) { 29 match macro_call(p) {
30 MacroFlavor::Curly => (), 30 BlockLike::Block => (),
31 MacroFlavor::NonCurly => { 31 BlockLike::NotBlock => {
32 p.expect(SEMI); 32 p.expect(SEMI);
33 } 33 }
34 } 34 }
@@ -277,32 +277,27 @@ fn mod_item(p: &mut Parser) {
277 } 277 }
278} 278}
279 279
280pub(super) enum MacroFlavor { 280fn macro_call(p: &mut Parser) -> BlockLike {
281 Curly,
282 NonCurly,
283}
284
285fn macro_call(p: &mut Parser) -> MacroFlavor {
286 assert!(paths::is_path_start(p)); 281 assert!(paths::is_path_start(p));
287 paths::use_path(p); 282 paths::use_path(p);
288 macro_call_after_excl(p) 283 macro_call_after_excl(p)
289} 284}
290 285
291pub(super) fn macro_call_after_excl(p: &mut Parser) -> MacroFlavor { 286pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike {
292 p.expect(EXCL); 287 p.expect(EXCL);
293 p.eat(IDENT); 288 p.eat(IDENT);
294 let flavor = match p.current() { 289 let flavor = match p.current() {
295 L_CURLY => { 290 L_CURLY => {
296 token_tree(p); 291 token_tree(p);
297 MacroFlavor::Curly 292 BlockLike::Block
298 } 293 }
299 L_PAREN | L_BRACK => { 294 L_PAREN | L_BRACK => {
300 token_tree(p); 295 token_tree(p);
301 MacroFlavor::NonCurly 296 BlockLike::NotBlock
302 } 297 }
303 _ => { 298 _ => {
304 p.error("expected `{`, `[`, `(`"); 299 p.error("expected `{`, `[`, `(`");
305 MacroFlavor::NonCurly 300 BlockLike::NotBlock
306 }, 301 },
307 }; 302 };
308 303
diff --git a/src/grammar/mod.rs b/src/grammar/mod.rs
index b558da477..1b997d861 100644
--- a/src/grammar/mod.rs
+++ b/src/grammar/mod.rs
@@ -43,6 +43,12 @@ pub(crate) fn file(p: &mut Parser) {
43 file.complete(p, FILE); 43 file.complete(p, FILE);
44} 44}
45 45
46
47enum BlockLike {
48 Block,
49 NotBlock,
50}
51
46fn visibility(p: &mut Parser) { 52fn visibility(p: &mut Parser) {
47 if p.at(PUB_KW) { 53 if p.at(PUB_KW) {
48 let vis = p.start(); 54 let vis = p.start();