fn extract_assertion(&mut self) -> syn::Result<ast::Assertion> {
        while !self.input.is_empty() {
            if self.input.check_keyword("forall") {
                unimplemented!("check_forall_keyword");
            } else if self.input.check_keyword("after_expiry") {
                unimplemented!("after_expiry_keyword");
            } else if self.input.check_operator("==>") {
                self.convert_expr_into_conjunct()?;
                let mut parser = Parser {
                    input: mem::replace(&mut self.input, ParserStream::empty()),
                    conjuncts: Vec::new(),
                    expr: Vec::new(),
                    consumed_expression: false,
                };
                let lhs = self.conjuncts_to_assertion()?;
                let rhs = parser.extract_assertion()?;
                assert!(parser.is_finished());
                let implication = common::Implication {
                    lhs: Box::new(lhs),
                    rhs: Box::new(rhs),
                };
                return Ok(common::Assertion::Implication(implication));
            } else if self.input.check_operator("&&") {
                self.convert_expr_into_conjunct()?;
                if self.input.is_empty() {
                    return Err(self.missing_assertion_error());
                }
            } else if let Some(group) = self.input.check_nested_assertion() {
                if self.expr.is_empty() && (self.input.is_empty() || self.input.peek_any_operator())
                {
                    // We potentially have a nested expression.
                    let mut parser = Parser::new(group.stream());
                    let conjunct = parser.extract_assertion()?;
                    assert!(parser.is_finished());
                    if let common::Assertion::Expression(expression) = conjunct {
                        self.expr.extend(expression.body)
                    } else {
                        self.conjuncts.push(conjunct);
                        self.consumed_expression = true;
                    }
                } else {
                    self.expr.push(TokenTree::Group(group));
                }
            } else {
                let token = self.input.pop().unwrap();
                self.expr.push(token);
            }
        }
        if !self.expr.is_empty() {
            let expression = self.new_expr();
            self.conjuncts
                .push(common::Assertion::Expression(expression));
        }
        self.conjuncts_to_assertion()
    }
/// Traverse the tokens and reconstruct the high-level structure of the assertion.
///
/// Grammar (note that the first match wins):
///
/// ```plain
/// assertion :=
///     { conjunct '&&' } forall { '&&' conjunct } |
///     implication |
///     conjunct { '&&' conjunct }
/// forall = 'forall' '|' args '|' assertion 'triggers' '{' rust_expression '}'
/// implication = conjunct { '&&' conjunct } '==>' conjunct { '&&' conjunct }
/// conjunct := '(' assertion ')' | '{' assertion '}' | '[' assertion ']' | pledge
/// pledge := 'after_expiry' [ '<' identifier '>' ] '(' assertion ')'
/// conjunct := rust_expression     // if failed to match any of the above, treat as
///                                 // a Rust expression
/// ```
Traverse the tokens and reconstruct the high-level structure of the assertion.
Grammar (note that the first match wins).


Traverse the tokens and reconstruct the high - level structure of the assertion . Grammar ( note that the first match wins ) .
fn extract_assertion(&mut self) -> syn::Result<ast::Assertion> {
        while !self.input.is_empty() {
            if self.input.check_keyword("forall") {
                unimplemented!("check_forall_keyword");
            } else if self.input.check_keyword("after_expiry") {
                unimplemented!("after_expiry_keyword");
            } else if self.input.check_operator("==>") {
                self.convert_expr_into_conjunct()?;
                let mut parser = Parser {
                    input: mem::replace(&mut self.input, ParserStream::empty()),
                    conjuncts: Vec::new(),
                    expr: Vec::new(),
                    consumed_expression: false,
                };
                let lhs = self.conjuncts_to_assertion()?;
                let rhs = parser.extract_assertion()?;
                assert!(parser.is_finished());
                let implication = common::Implication {
                    lhs: Box::new(lhs),
                    rhs: Box::new(rhs),
                };
                return Ok(common::Assertion::Implication(implication));
            } else if self.input.check_operator("&&") {
                self.convert_expr_into_conjunct()?;
                if self.input.is_empty() {
                    return Err(self.missing_assertion_error());
                }
            } else if let Some(group) = self.input.check_nested_assertion() {
                if self.expr.is_empty() && (self.input.is_empty() || self.input.peek_any_operator())
                {
                    // We potentially have a nested expression.
                    let mut parser = Parser::new(group.stream());
                    let conjunct = parser.extract_assertion()?;
                    assert!(parser.is_finished());
                    if let common::Assertion::Expression(expression) = conjunct {
                        self.expr.extend(expression.body)
                    } else {
                        self.conjuncts.push(conjunct);
                        self.consumed_expression = true;
                    }
                } else {
                    self.expr.push(TokenTree::Group(group));
                }
            } else {
                let token = self.input.pop().unwrap();
                self.expr.push(token);
            }
        }
        if !self.expr.is_empty() {
            let expression = self.new_expr();
            self.conjuncts
                .push(common::Assertion::Expression(expression));
        }
        self.conjuncts_to_assertion()
    }
fn extract_assertion ( & mut self ) -> syn :: Result < ast :: Assertion > { while ! self . input . is_empty ( ) { if self . input . check_keyword ( " " ) { unimplemented ! ( " " ) ; } else if self . input . check_keyword ( " " ) { unimplemented ! ( " " ) ; } else if self . input . check_operator ( " " ) { self . convert_expr_into_conjunct ( ) ? ; let mut parser = Parser { input : mem :: replace ( & mut self . input , ParserStream :: empty ( ) ) , conjuncts : Vec :: new ( ) , expr : Vec :: new ( ) , consumed_expression : false , } ; let lhs = self . conjuncts_to_assertion ( ) ? ; let rhs = parser . extract_assertion ( ) ? ; assert ! ( parser is_finished ( ) ) ; let implication = common :: Implication { lhs : Box :: new ( lhs ) , rhs : Box :: new ( rhs ) , } ; return Ok ( common :: Assertion :: Implication ( implication ) ) ; } else if self . input . check_operator ( " " ) { self . convert_expr_into_conjunct ( ) ? ; if self . input . is_empty ( ) { return Err ( self . missing_assertion_error ( ) ) ; } } else if let Some ( group ) = self . input . check_nested_assertion ( ) { if self . expr . is_empty ( ) && ( self . input . is_empty ( ) || self . input . peek_any_operator ( ) ) { // We potentially have a nested expression. let mut parser = Parser :: new ( group . stream ( ) ) ; let conjunct = parser . extract_assertion ( ) ? ; assert ! ( parser is_finished ( ) ) ; if let common :: Assertion :: Expression ( expression ) = conjunct { self . expr . extend ( expression . body ) } else { self . conjuncts . push ( conjunct ) ; self . consumed_expression = true ; } } else { self . expr . push ( TokenTree :: Group ( group ) ) ; } } else { let token = self . input . pop ( ) . unwrap ( ) ; self . expr . push ( token ) ; } } if ! self . expr . is_empty ( ) { let expression = self . new_expr ( ) ; self . conjuncts . push ( common :: Assertion :: Expression ( expression ) ) ; } self . conjuncts_to_assertion ( ) }
Traverse the tokens and reconstruct the high-level structure of the assertion.
Traverse the tokens and reconstruct the high - level structure of the assertion .
&mut self