fn parse_macro_use_or_failure(
        &mut self,
        attrs: Vec<Attribute> ,
        macros_allowed: bool,
        attributes_allowed: bool,
        lo: BytePos,
        visibility: Visibility
    ) -> PResult<'a, Option<P<Item>>> {
        if macros_allowed && !self.token.is_any_keyword()
                && self.look_ahead(1, |t| *t == token::Not)
                && (self.look_ahead(2, |t| t.is_plain_ident())
                    || self.look_ahead(2, |t| *t == token::OpenDelim(token::Paren))
                    || self.look_ahead(2, |t| *t == token::OpenDelim(token::Brace))) {
            // MACRO INVOCATION ITEM

            let last_span = self.last_span;
            self.complain_if_pub_macro(visibility, last_span);

            let mac_lo = self.span.lo;

            // item macro.
            let pth = try!(self.parse_path(NoTypesAllowed));
            try!(self.expect(&token::Not));

            // a 'special' identifier (like what `macro_rules!` uses)
            // is optional. We should eventually unify invoc syntax
            // and remove this.
            let id = if self.token.is_plain_ident() {
                try!(self.parse_ident())
            } else {
                token::special_idents::invalid // no special identifier
            };
            // eat a matched-delimiter token tree:
            let delim = try!(self.expect_open_delim());
            let tts = try!(self.parse_seq_to_end(&token::CloseDelim(delim),
                                                 SeqSep::none(),
                                                 |p| p.parse_token_tree()));
            // single-variant-enum... :
            let m = Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT };
            let m: ast::Mac = codemap::Spanned { node: m,
                                             span: mk_sp(mac_lo,
                                                         self.last_span.hi) };

            if delim != token::Brace {
                if !self.eat(&token::Semi) {
                    let last_span = self.last_span;
                    self.span_err(last_span,
                                  "macros that expand to items must either \
                                   be surrounded with braces or followed by \
                                   a semicolon");
                }
            }

            let item_ = ItemKind::Mac(m);
            let last_span = self.last_span;
            let item = self.mk_item(lo,
                                    last_span.hi,
                                    id,
                                    item_,
                                    visibility,
                                    attrs);
            return Ok(Some(item));
        }

        // FAILURE TO PARSE ITEM
        match visibility {
            Visibility::Inherited => {}
            Visibility::Public => {
                let last_span = self.last_span;
                return Err(self.span_fatal(last_span, "unmatched visibility `pub`"));
            }
        }

        if !attributes_allowed && !attrs.is_empty() {
            self.expected_item_err(&attrs);
        }
        Ok(None)
    }
/// This is the fall-through for parsing items.
This is the fall-through for parsing items.
This is the fall - through for parsing items .
fn parse_macro_use_or_failure(
        &mut self,
        attrs: Vec<Attribute> ,
        macros_allowed: bool,
        attributes_allowed: bool,
        lo: BytePos,
        visibility: Visibility
    ) -> PResult<'a, Option<P<Item>>> {
        if macros_allowed && !self.token.is_any_keyword()
                && self.look_ahead(1, |t| *t == token::Not)
                && (self.look_ahead(2, |t| t.is_plain_ident())
                    || self.look_ahead(2, |t| *t == token::OpenDelim(token::Paren))
                    || self.look_ahead(2, |t| *t == token::OpenDelim(token::Brace))) {
            // MACRO INVOCATION ITEM
            let last_span = self.last_span;
            self.complain_if_pub_macro(visibility, last_span);
            let mac_lo = self.span.lo;
            // item macro.
            let pth = try!(self.parse_path(NoTypesAllowed));
            try!(self.expect(&token::Not));
            // a 'special' identifier (like what `macro_rules!` uses)
            // is optional. We should eventually unify invoc syntax
            // and remove this.
            let id = if self.token.is_plain_ident() {
                try!(self.parse_ident())
            } else {
                token::special_idents::invalid // no special identifier
            };
            // eat a matched-delimiter token tree:
            let delim = try!(self.expect_open_delim());
            let tts = try!(self.parse_seq_to_end(&token::CloseDelim(delim),
                                                 SeqSep::none(),
                                                 |p| p.parse_token_tree()));
            // single-variant-enum... :
            let m = Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT };
            let m: ast::Mac = codemap::Spanned { node: m,
                                             span: mk_sp(mac_lo,
                                                         self.last_span.hi) };
            if delim != token::Brace {
                if !self.eat(&token::Semi) {
                    let last_span = self.last_span;
                    self.span_err(last_span,
                                  "macros that expand to items must either \
                                   be surrounded with braces or followed by \
                                   a semicolon");
                }
            }
            let item_ = ItemKind::Mac(m);
            let last_span = self.last_span;
            let item = self.mk_item(lo,
                                    last_span.hi,
                                    id,
                                    item_,
                                    visibility,
                                    attrs);
            return Ok(Some(item));
        }
        // FAILURE TO PARSE ITEM
        match visibility {
            Visibility::Inherited => {}
            Visibility::Public => {
                let last_span = self.last_span;
                return Err(self.span_fatal(last_span, "unmatched visibility `pub`"));
            }
        }
        if !attributes_allowed && !attrs.is_empty() {
            self.expected_item_err(&attrs);
        }
        Ok(None)
    }
fn parse_macro_use_or_failure ( & mut self , attrs : Vec < Attribute > , macros_allowed : bool , attributes_allowed : bool , lo : BytePos , visibility : Visibility ) -> PResult < ' a , Option < P < Item > > > { if macros_allowed && ! self . token . is_any_keyword ( ) && self . look_ahead ( 1 , | t | * t == token :: Not ) && ( self . look_ahead ( 2 , | t | t . is_plain_ident ( ) ) || self . look_ahead ( 2 , | t | * t == token :: OpenDelim ( token :: Paren ) ) || self . look_ahead ( 2 , | t | * t == token :: OpenDelim ( token :: Brace ) ) ) { // MACRO INVOCATION ITEM let last_span = self . last_span ; self . complain_if_pub_macro ( visibility , last_span ) ; let mac_lo = self . span . lo ; // item macro. let pth = try ! ( self parse_path ( NoTypesAllowed ) ) ; try ! ( self expect ( token Not ) ) ; // a 'special' identifier (like what `macro_rules!` uses) // is optional. We should eventually unify invoc syntax // and remove this. let id = if self . token . is_plain_ident ( ) { try ! ( self parse_ident ( ) ) } else { token :: special_idents :: invalid // no special identifier } ; // eat a matched-delimiter token tree: let delim = try ! ( self expect_open_delim ( ) ) ; let tts = try ! ( self parse_seq_to_end ( token CloseDelim ( delim ) SeqSep none ( ) p p parse_token_tree ( ) ) ) ; // single-variant-enum... : let m = Mac_ { path : pth , tts : tts , ctxt : EMPTY_CTXT } ; let m : ast :: Mac = codemap :: Spanned { node : m , span : mk_sp ( mac_lo , self . last_span . hi ) } ; if delim != token :: Brace { if ! self . eat ( & token :: Semi ) { let last_span = self . last_span ; self . span_err ( last_span , " \
 \
 " ) ; } } let item_ = ItemKind :: Mac ( m ) ; let last_span = self . last_span ; let item = self . mk_item ( lo , last_span . hi , id , item_ , visibility , attrs ) ; return Ok ( Some ( item ) ) ; } // FAILURE TO PARSE ITEM match visibility { Visibility :: Inherited => { } Visibility :: Public => { let last_span = self . last_span ; return Err ( self . span_fatal ( last_span , " " ) ) ; } } if ! attributes_allowed && ! attrs . is_empty ( ) { self . expected_item_err ( & attrs ) ; } Ok ( None ) }
This is the fall-through for parsing items.
This is the fall - through for parsing items .
&mut self
attrs
Vec<Attribute>
macros_allowed
bool
attributes_allowed
bool
lo
BytePos
visibility
Visibility
&mut self
attrs
Vec<Attribute>
macros_allowed
bool
attributes_allowed
bool
lo
BytePos
visibility
Visibility