diff options
author | Aleksey Kladov <[email protected]> | 2018-08-05 12:16:38 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-05 12:16:38 +0100 |
commit | 5691da4c84655e0d966ac11406fa7a90bdd02643 (patch) | |
tree | 566597ece1387006e3c8e55d82c5f93ed55ee112 /src | |
parent | c871022f9810547f3eeaa5af3a3dc4bc0c85a386 (diff) |
Expr macros
Diffstat (limited to 'src')
-rw-r--r-- | src/grammar/expressions/mod.rs | 16 | ||||
-rw-r--r-- | src/grammar/items/mod.rs | 6 |
2 files changed, 16 insertions, 6 deletions
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) { | |||
202 | // let _ = a; | 202 | // let _ = a; |
203 | // let _ = a::b; | 203 | // let _ = a::b; |
204 | // let _ = ::a::<b>; | 204 | // let _ = ::a::<b>; |
205 | // let _ = format!(); | ||
205 | // } | 206 | // } |
206 | fn path_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker { | 207 | fn path_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker { |
207 | assert!(paths::is_path_start(p)); | 208 | assert!(paths::is_path_start(p)); |
208 | let m = p.start(); | 209 | let m = p.start(); |
209 | paths::expr_path(p); | 210 | paths::expr_path(p); |
210 | if p.at(L_CURLY) && !r.forbid_structs { | 211 | match p.current() { |
211 | struct_lit(p); | 212 | L_CURLY if !r.forbid_structs => { |
212 | m.complete(p, STRUCT_LIT) | 213 | struct_lit(p); |
213 | } else { | 214 | m.complete(p, STRUCT_LIT) |
214 | m.complete(p, PATH_EXPR) | 215 | } |
216 | EXCL => { | ||
217 | items::macro_call_after_excl(p); | ||
218 | m.complete(p, MACRO_CALL) | ||
219 | } | ||
220 | _ => m.complete(p, PATH_EXPR) | ||
215 | } | 221 | } |
216 | } | 222 | } |
217 | 223 | ||
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) { | |||
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | enum MacroFlavor { | 280 | pub(super) enum MacroFlavor { |
281 | Curly, | 281 | Curly, |
282 | NonCurly, | 282 | NonCurly, |
283 | } | 283 | } |
@@ -285,6 +285,10 @@ enum MacroFlavor { | |||
285 | fn macro_call(p: &mut Parser) -> MacroFlavor { | 285 | fn macro_call(p: &mut Parser) -> MacroFlavor { |
286 | assert!(paths::is_path_start(p)); | 286 | assert!(paths::is_path_start(p)); |
287 | paths::use_path(p); | 287 | paths::use_path(p); |
288 | macro_call_after_excl(p) | ||
289 | } | ||
290 | |||
291 | pub(super) fn macro_call_after_excl(p: &mut Parser) -> MacroFlavor { | ||
288 | p.expect(EXCL); | 292 | p.expect(EXCL); |
289 | p.eat(IDENT); | 293 | p.eat(IDENT); |
290 | let flavor = match p.current() { | 294 | let flavor = match p.current() { |