pub fn scan_gap(gap: &str, expected: &[&'static str]) -> Vec<GapPiece>Expand description
Scans the raw text of a grammatically-constrained gap — whitespace, ////* */ comments, and
exactly the literal tokens in expected, in that order — returning every comment found plus
every expected token, interleaved in source order. Block comments nest; their inner
delimiters and text remain intact apart from per-line whitespace normalization.
-
Postcondition: the result contains each element of
expectedexactly once, as aGapPiece::Punct, inexpected’s order, regardless of how much ofgapactually matched (an empty or syntheticgapstill yields all expected tokens, so a hand-builtExprwith no real source re-synthesizes its separators). -
Complexity: O(n) in
gap.len().