Function esparse::skip::balanced_parens[][src]

pub fn balanced_parens<'f, 's>(
    lex: &mut Lexer<'f, 's>,
    nesting: usize
) -> Result<()>

Skip a balanced tree of parentheses, i.e., ( and ).

nesting should be nonzero, and describes the depth of parenthesis nesting the lexer is at when entering this function.

Examples

use esparse::{lex, skip};

let mut lexer = lex::Lexer::new_unnamed("(1 * (2 + 3)) ** 4");
assert_eq!(lexer.advance().tt, lex::Tt::Lparen);
skip::balanced_parens(&mut lexer, 1)?;
assert_eq!(lexer.here().tt, lex::Tt::StarStar);