pub fn parse_statement(parser: &mut Parser) -> Result<Statement, ParserErrorKind> {
        match parser.curr_token.token().to_declaration_keyword() {
            Keyword::Let => Ok(Statement::Let(parse_let_statement(parser)?)),
            Keyword::Const => Ok(Statement::Const(parse_const_statement(parser)?)),
            Keyword::Priv => Ok(Statement::Private(parse_private_statement(parser)?)),
            kw => {
                let msg = format!("the keyword {} cannot be used to declare a statement. Please use `let`, `const` or `priv`", kw);
                Err(ParserErrorKind::UnstructuredError {
                    span: parser.curr_token.to_span(),
                    message: msg,
                })
            }
        }
    }
/// Parses a generic declaration statement. The token parameter determines what type of statement will be parsed
///
/// XXX: We can make this clearer by further separating keywords into declaration keywords.
/// This would ensure that the match statement will always be exhaustive on the list
/// of declaration keywords.
Parses a generic declaration statement. The token parameter determines what type of statement will be parsed
XXX: We can make this clearer by further separating keywords into declaration keywords.
This would ensure that the match statement will always be exhaustive on the list
of declaration keywords.
Parses a generic declaration statement . The token parameter determines what type of statement will be parsed XXX : We can make this clearer by further separating keywords into declaration keywords . This would ensure that the match statement will always be exhaustive on the list of declaration keywords .
pub fn parse_statement(parser: &mut Parser) -> Result<Statement, ParserErrorKind> {
        match parser.curr_token.token().to_declaration_keyword() {
            Keyword::Let => Ok(Statement::Let(parse_let_statement(parser)?)),
            Keyword::Const => Ok(Statement::Const(parse_const_statement(parser)?)),
            Keyword::Priv => Ok(Statement::Private(parse_private_statement(parser)?)),
            kw => {
                let msg = format!("the keyword {} cannot be used to declare a statement. Please use `let`, `const` or `priv`", kw);
                Err(ParserErrorKind::UnstructuredError {
                    span: parser.curr_token.to_span(),
                    message: msg,
                })
            }
        }
    }
pub fn parse_statement ( parser : & mut Parser ) -> Result < Statement , ParserErrorKind > { match parser . curr_token . token ( ) . to_declaration_keyword ( ) { Keyword :: Let => Ok ( Statement :: Let ( parse_let_statement ( parser ) ? ) ) , Keyword :: Const => Ok ( Statement :: Const ( parse_const_statement ( parser ) ? ) ) , Keyword :: Priv => Ok ( Statement :: Private ( parse_private_statement ( parser ) ? ) ) , kw => { let msg = format ! ( " " kw ) ; Err ( ParserErrorKind :: UnstructuredError { span : parser . curr_token . to_span ( ) , message : msg , } ) } } }
Parses a generic declaration statement.
Parses a generic declaration statement .
parser
&mut Parser
parser
&mut Parser