Skip to main content

render_parse_errors

Function render_parse_errors 

Source
pub fn render_parse_errors<W: Write>(
    errors: &[Rich<'_, Token, SimpleSpan>],
    src: &str,
    source_name: &str,
    writer: &mut W,
) -> Result<()>
Expand description

Render chumsky Rich parse errors as ariadne diagnostics, writing to writer.

Each error produces one ariadne Report with:

  • A primary span underlining the offending token and a "found X — expected Y" message.
  • Secondary labels for each .labelled("…") context that was active when the error occurred — e.g. "while parsing expression" or "while parsing declaration". These help orient the user in larger constructs.

§Errors

Propagates any std::io::Error from writing to writer.