From 7094291573dc819e3115950ec3b2316bd5e9ea33 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 16 Aug 2018 12:51:40 +0300 Subject: tt-attrs --- crates/libsyntax2/src/grammar/attributes.rs | 56 +++-------------------------- 1 file changed, 4 insertions(+), 52 deletions(-) (limited to 'crates/libsyntax2/src/grammar/attributes.rs') diff --git a/crates/libsyntax2/src/grammar/attributes.rs b/crates/libsyntax2/src/grammar/attributes.rs index c411d4d7f..cd30e8a45 100644 --- a/crates/libsyntax2/src/grammar/attributes.rs +++ b/crates/libsyntax2/src/grammar/attributes.rs @@ -22,58 +22,10 @@ fn attribute(p: &mut Parser, inner: bool) { p.bump(); } - if p.expect(L_BRACK) { - meta_item(p); - p.expect(R_BRACK); - } - attr.complete(p, ATTR); -} - -fn meta_item(p: &mut Parser) { - if p.at(IDENT) { - let meta_item = p.start(); - p.bump(); - match p.current() { - EQ => { - p.bump(); - if expressions::literal(p).is_none() { - p.error("expected literal"); - } - } - L_PAREN => meta_item_arg_list(p), - _ => (), - } - meta_item.complete(p, META_ITEM); + if p.at(L_BRACK) { + items::token_tree(p); } else { - p.error("expected attribute value"); - } -} - -fn meta_item_arg_list(p: &mut Parser) { - assert!(p.at(L_PAREN)); - p.bump(); - loop { - match p.current() { - EOF | R_PAREN => break, - IDENT => meta_item(p), - c => if expressions::literal(p).is_none() { - let message = "expected attribute"; - - if items::ITEM_FIRST.contains(c) { - p.error(message); - return; - } - - let err = p.start(); - p.error(message); - p.bump(); - err.complete(p, ERROR); - continue; - }, - } - if !p.at(R_PAREN) { - p.expect(COMMA); - } + p.error("expected `[`"); } - p.expect(R_PAREN); + attr.complete(p, ATTR); } -- cgit v1.2.3