aboutsummaryrefslogtreecommitdiff
path: root/src/grammar/items
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-07 14:11:40 +0100
committerAleksey Kladov <[email protected]>2018-08-07 14:11:40 +0100
commit0ab1e255ee5c70aedd4d243e0e11109fc4bbcef2 (patch)
tree52c30676af9f4b20bd8daff37be7c3225b3c3672 /src/grammar/items
parent42e3a8ef77d75cdd0abf4f0729082a112beefb67 (diff)
Generalize blocklike
Diffstat (limited to 'src/grammar/items')
-rw-r--r--src/grammar/items/mod.rs19
1 files changed, 7 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