Skip to main content

scan_gap

Function scan_gap 

Source
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 expected exactly once, as a GapPiece::Punct, in expected’s order, regardless of how much of gap actually matched (an empty or synthetic gap still yields all expected tokens, so a hand-built Expr with no real source re-synthesizes its separators).

  • Complexity: O(n) in gap.len().