Skip to main content

parse_program_spanned

Function parse_program_spanned 

Source
pub fn parse_program_spanned(src: &str) -> Result<Vec<(Sexp, Span)>, ParseError>
Expand description

Parse, keeping each top-level form’s source span.

The spans are what let the formatter put comments back. A comment is not part of a program’s meaning, so it has no place in the Sexp tree — putting it there would break canonicality, since two programs differing only in a comment would stop formatting identically. Instead the formatter renders the tree and re-interleaves comments by position, which needs to know where each form started and ended.