[][src]Function spaik::sexpr_parse::find_pairs

pub fn find_pairs(
    pairs: &[(&str, &str)],
    toks: &[Token<'_>]
) -> PResult<FnvHashMap<u32, u32>>

Find pairs of delimiters inside a token array.

Arguments

  • pairs : List of pairs, e.g [("(", ")"), ("[", "]"), ("{", "}")]
  • toks : Token array.

Returns

A hashmap map, where map[idx] contains the position of the closing delimiter that closes the opening delimiter at idx

Time complexity

O(n⋅m), where n is the number of tokens and m is the number of pairs.