pub(crate) fn parse_block_expression(
        parser: &mut Parser,
    ) -> Result<BlockExpression, ParserErrorKind> {
        let mut statements: Vec<Statement> = Vec::new();

        // XXX: Check consistency with for parser, if parser and func parser
        if parser.curr_token != Token::LeftBrace {
            return Err(ParserErrorKind::UnstructuredError {
                message: "Expected a { to start the block expression".to_string(),
                span: parser.curr_token.to_span(),
            });
        }
        parser.advance_tokens();

        while (parser.curr_token != Token::RightBrace) && (parser.curr_token != Token::EOF) {
            statements.push(parser.parse_statement()?);
            parser.advance_tokens();
        }

        if parser.curr_token != Token::RightBrace {
            return Err(ParserErrorKind::UnstructuredError {
                message: "Expected a } to end the block expression".to_string(),
                span: parser.curr_token.to_span(),
            });
        }

        Ok(BlockExpression(statements))
    }
/// Parses a Block, returns a BlockExpression.
/// This is useful for when the AST Node, will always contain a
/// BlockExpression, hence parsing it through the BlockParser
/// which returns an ExpressionKind is redundant.
Parses a Block, returns a BlockExpression.
This is useful for when the AST Node, will always contain a
BlockExpression, hence parsing it through the BlockParser
which returns an ExpressionKind is redundant.
Parses a Block returns a BlockExpression . This is useful for when the AST Node will always contain a BlockExpression hence parsing it through the BlockParser which returns an ExpressionKind is redundant .
pub(crate) fn parse_block_expression(
        parser: &mut Parser,
    ) -> Result<BlockExpression, ParserErrorKind> {
        let mut statements: Vec<Statement> = Vec::new();
        // XXX: Check consistency with for parser, if parser and func parser
        if parser.curr_token != Token::LeftBrace {
            return Err(ParserErrorKind::UnstructuredError {
                message: "Expected a { to start the block expression".to_string(),
                span: parser.curr_token.to_span(),
            });
        }
        parser.advance_tokens();
        while (parser.curr_token != Token::RightBrace) && (parser.curr_token != Token::EOF) {
            statements.push(parser.parse_statement()?);
            parser.advance_tokens();
        }
        if parser.curr_token != Token::RightBrace {
            return Err(ParserErrorKind::UnstructuredError {
                message: "Expected a } to end the block expression".to_string(),
                span: parser.curr_token.to_span(),
            });
        }
        Ok(BlockExpression(statements))
    }
pub ( crate ) fn parse_block_expression ( parser : & mut Parser , ) -> Result < BlockExpression , ParserErrorKind > { let mut statements : Vec < Statement > = Vec :: new ( ) ; // XXX: Check consistency with for parser, if parser and func parser if parser . curr_token != Token :: LeftBrace { return Err ( ParserErrorKind :: UnstructuredError { message : " " . to_string ( ) , span : parser . curr_token . to_span ( ) , } ) ; } parser . advance_tokens ( ) ; while ( parser . curr_token != Token :: RightBrace ) && ( parser . curr_token != Token :: EOF ) { statements . push ( parser . parse_statement ( ) ? ) ; parser . advance_tokens ( ) ; } if parser . curr_token != Token :: RightBrace { return Err ( ParserErrorKind :: UnstructuredError { message : " " . to_string ( ) , span : parser . curr_token . to_span ( ) , } ) ; } Ok ( BlockExpression ( statements ) ) }
Parses a Block, returns a BlockExpression.
Parses a Block returns a BlockExpression .
parser
&mut Parser
parser
&mut Parser