From 5691da4c84655e0d966ac11406fa7a90bdd02643 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 5 Aug 2018 14:16:38 +0300 Subject: Expr macros --- src/grammar/expressions/mod.rs | 16 +++++++++++----- src/grammar/items/mod.rs | 6 +++++- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/grammar/expressions/mod.rs b/src/grammar/expressions/mod.rs index 6831aef66..15669f99d 100644 --- a/src/grammar/expressions/mod.rs +++ b/src/grammar/expressions/mod.rs @@ -202,16 +202,22 @@ fn arg_list(p: &mut Parser) { // let _ = a; // let _ = a::b; // let _ = ::a::; +// let _ = format!(); // } fn path_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker { assert!(paths::is_path_start(p)); let m = p.start(); paths::expr_path(p); - if p.at(L_CURLY) && !r.forbid_structs { - struct_lit(p); - m.complete(p, STRUCT_LIT) - } else { - m.complete(p, PATH_EXPR) + match p.current() { + L_CURLY if !r.forbid_structs => { + struct_lit(p); + m.complete(p, STRUCT_LIT) + } + EXCL => { + items::macro_call_after_excl(p); + m.complete(p, MACRO_CALL) + } + _ => m.complete(p, PATH_EXPR) } } diff --git a/src/grammar/items/mod.rs b/src/grammar/items/mod.rs index 8f766901e..657078765 100644 --- a/src/grammar/items/mod.rs +++ b/src/grammar/items/mod.rs @@ -277,7 +277,7 @@ fn mod_item(p: &mut Parser) { } } -enum MacroFlavor { +pub(super) enum MacroFlavor { Curly, NonCurly, } @@ -285,6 +285,10 @@ enum MacroFlavor { fn macro_call(p: &mut Parser) -> MacroFlavor { 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 { p.expect(EXCL); p.eat(IDENT); let flavor = match p.current() { -- cgit v1.2.3