fn parse_block(&mut self) -> Result<Vec<Stmt>, SyntaxError> {
        let opening_delimiter = self.previous.clone();

        let mut body = vec![];

        while !self.current.is_delimiter() {
            match self.current.token_type {
                // \n or //...
                TokenType::Newline | TokenType::Comment(_, false) => {
                    // should single-line comments be parsed?
                    self.advance();
                    continue;
                }
                // ...
                _ => body.push(self.parse_statement()?),
            };
        }

        let closing_delimiter = self.current.clone();

        match (&opening_delimiter.token_type, &closing_delimiter.token_type) {
            (TokenType::LeftBrace, TokenType::RightBrace)
            | (TokenType::Then, TokenType::EndIf)
            | (TokenType::Then, TokenType::Else)
            | (TokenType::Else, TokenType::EndIf)
            | (TokenType::Loop, TokenType::EndLoop)
            | (TokenType::LeftParen, TokenType::RightParen) => Ok(body),
            _ => {
                let err_kind = SyntaxErrorKind::MismatchedDelimiter {
                    first: Item::new(&opening_delimiter.span, opening_delimiter.syntax()),
                    second: Item::new(&closing_delimiter.span, closing_delimiter.syntax()),
                };

                let err = self.error(err_kind);

                Err(err)
            }
        }
    }
/// Parse everything up to, but not including, a delimiter.
Parse everything up to, but not including, a delimiter.
Parse everything up to but not including a delimiter .
fn parse_block(&mut self) -> Result<Vec<Stmt>, SyntaxError> {
        let opening_delimiter = self.previous.clone();
        let mut body = vec![];
        while !self.current.is_delimiter() {
            match self.current.token_type {
                // \n or //...
                TokenType::Newline | TokenType::Comment(_, false) => {
                    // should single-line comments be parsed?
                    self.advance();
                    continue;
                }
                // ...
                _ => body.push(self.parse_statement()?),
            };
        }
        let closing_delimiter = self.current.clone();
        match (&opening_delimiter.token_type, &closing_delimiter.token_type) {
            (TokenType::LeftBrace, TokenType::RightBrace)
            | (TokenType::Then, TokenType::EndIf)
            | (TokenType::Then, TokenType::Else)
            | (TokenType::Else, TokenType::EndIf)
            | (TokenType::Loop, TokenType::EndLoop)
            | (TokenType::LeftParen, TokenType::RightParen) => Ok(body),
            _ => {
                let err_kind = SyntaxErrorKind::MismatchedDelimiter {
                    first: Item::new(&opening_delimiter.span, opening_delimiter.syntax()),
                    second: Item::new(&closing_delimiter.span, closing_delimiter.syntax()),
                };
                let err = self.error(err_kind);
                Err(err)
            }
        }
    }
fn parse_block ( & mut self ) -> Result < Vec < Stmt > , SyntaxError > { let opening_delimiter = self . previous . clone ( ) ; let mut body = vec ! [ ] ; while ! self . current . is_delimiter ( ) { match self . current . token_type { // \n or //... TokenType :: Newline | TokenType :: Comment ( _ , false ) => { // should single-line comments be parsed? self . advance ( ) ; continue ; } // ... _ => body . push ( self . parse_statement ( ) ? ) , } ; } let closing_delimiter = self . current . clone ( ) ; match ( & opening_delimiter . token_type , & closing_delimiter . token_type ) { ( TokenType :: LeftBrace , TokenType :: RightBrace ) | ( TokenType :: Then , TokenType :: EndIf ) | ( TokenType :: Then , TokenType :: Else ) | ( TokenType :: Else , TokenType :: EndIf ) | ( TokenType :: Loop , TokenType :: EndLoop ) | ( TokenType :: LeftParen , TokenType :: RightParen ) => Ok ( body ) , _ => { let err_kind = SyntaxErrorKind :: MismatchedDelimiter { first : Item :: new ( & opening_delimiter . span , opening_delimiter . syntax ( ) ) , second : Item :: new ( & closing_delimiter . span , closing_delimiter . syntax ( ) ) , } ; let err = self . error ( err_kind ) ; Err ( err ) } } }
Parse everything up to, but not including, a delimiter.
Parse everything up to but not including a delimiter .
&mut self