fn parse_import_decl(&mut self) -> PResult<ast::ImportDecl> {
        trace!("parse_import_decl");
        // Grammar:
        //
        // ```
        // ImportDecl       = "import" ( ImportSpec | "(" { ImportSpec ";" } ")" ) .
        // ```

        try!(self.eat(TokenKind::Import));
        let mut specs = Vec::new();

        match self.token.kind {
            // Long import declaration.
            TokenKind::LParen => {
                self.bump();

                // There may be multiple `ImportSpec`s in a single "long" import declaration.
                loop {
                    match self.token.kind {
                        // XXX: Should we _know_ that import specs always start with a string
                        // literal? I'm not sure.
                        TokenKind::RParen => {
                            break;
                        }
                        _ => {
                            specs.push(try_span!(self, self.parse_import_spec()));
                        }
                    }
                }
            }
            // Short import (single ImportSpec).
            _ => specs.push(try_span!(self, self.parse_import_spec())),
        }
        try!(self.eat(TokenKind::Semicolon));

        Ok(ast::ImportDecl { specs: specs })
    }
/// Parse an import declaration, which is made up of one or more import specs.
/// Simple example with a single spec: `import "fmt"`.
Parse an import declaration, which is made up of one or more import specs.
Simple example with a single spec: `import "fmt"`.
Parse an import declaration which is made up of one or more import specs . Simple example with a single spec : ` import " fmt " ` .
fn parse_import_decl(&mut self) -> PResult<ast::ImportDecl> {
        trace!("parse_import_decl");
        // Grammar:
        //
        // ```
        // ImportDecl       = "import" ( ImportSpec | "(" { ImportSpec ";" } ")" ) .
        // ```
        try!(self.eat(TokenKind::Import));
        let mut specs = Vec::new();
        match self.token.kind {
            // Long import declaration.
            TokenKind::LParen => {
                self.bump();
                // There may be multiple `ImportSpec`s in a single "long" import declaration.
                loop {
                    match self.token.kind {
                        // XXX: Should we _know_ that import specs always start with a string
                        // literal? I'm not sure.
                        TokenKind::RParen => {
                            break;
                        }
                        _ => {
                            specs.push(try_span!(self, self.parse_import_spec()));
                        }
                    }
                }
            }
            // Short import (single ImportSpec).
            _ => specs.push(try_span!(self, self.parse_import_spec())),
        }
        try!(self.eat(TokenKind::Semicolon));
        Ok(ast::ImportDecl { specs: specs })
    }
fn parse_import_decl ( & mut self ) -> PResult < ast :: ImportDecl > { trace ! ( " " ) ; // Grammar: // // ``` // ImportDecl       = "import" ( ImportSpec | "(" { ImportSpec ";" } ")" ) . // ``` try ! ( self eat ( TokenKind Import ) ) ; let mut specs = Vec :: new ( ) ; match self . token . kind { // Long import declaration. TokenKind :: LParen => { self . bump ( ) ; // There may be multiple `ImportSpec`s in a single "long" import declaration. loop { match self . token . kind { // XXX: Should we _know_ that import specs always start with a string // literal? I'm not sure. TokenKind :: RParen => { break ; } _ => { specs . push ( try_span ! ( self self parse_import_spec ( ) ) ) ; } } } } // Short import (single ImportSpec). _ => specs . push ( try_span ! ( self self parse_import_spec ( ) ) ) , } try ! ( self eat ( TokenKind Semicolon ) ) ; Ok ( ast :: ImportDecl { specs : specs } ) }
Parse an import declaration, which is made up of one or more import specs.
Parse an import declaration which is made up of one or more import specs .
&mut self