From c4173bb468500f6490921e8f8627d87b2aeb7af5 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sat, 17 Apr 2021 14:31:52 +0800 Subject: Handle extended key value attr in mbe --- crates/parser/src/grammar/attributes.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'crates/parser/src/grammar') diff --git a/crates/parser/src/grammar/attributes.rs b/crates/parser/src/grammar/attributes.rs index 96791ffc2..124a10eb2 100644 --- a/crates/parser/src/grammar/attributes.rs +++ b/crates/parser/src/grammar/attributes.rs @@ -14,6 +14,21 @@ pub(super) fn outer_attrs(p: &mut Parser) { } } +pub(super) fn meta(p: &mut Parser) { + paths::use_path(p); + + match p.current() { + T![=] => { + p.bump(T![=]); + if expressions::expr(p).0.is_none() { + p.error("expected expression"); + } + } + T!['('] | T!['['] | T!['{'] => items::token_tree(p), + _ => {} + } +} + fn attr(p: &mut Parser, inner: bool) { let attr = p.start(); assert!(p.at(T![#])); @@ -25,18 +40,7 @@ fn attr(p: &mut Parser, inner: bool) { } if p.eat(T!['[']) { - paths::use_path(p); - - match p.current() { - T![=] => { - p.bump(T![=]); - if expressions::expr(p).0.is_none() { - p.error("expected expression"); - } - } - T!['('] | T!['['] | T!['{'] => items::token_tree(p), - _ => {} - } + meta(p); if !p.eat(T![']']) { p.error("expected `]`"); -- cgit v1.2.3