eyg/parser/location
Render source-line context with carets under a span.
The same renderer is used for parse errors (single position widened into a one-character span) and runtime errors (whole-expression spans). The interpreter does not depend on this module — the CLI calls it after composing the interpreter’s description and hint.
Types
Values
pub fn is_empty(span: #(Int, Int)) -> Bool
Returns true when a span carries no location information.
pub fn source_context(
source: String,
span: #(Int, Int),
) -> List(String)
Render the source line(s) containing span with carets underneath.
- A zero-width span (
#(p, p)) renders a single^at columnp. - A single-line span renders
^characters spanning the range. - A multi-line span underlines from the start column to the end of the
first line, then renders subsequent lines (up to and including the line
containing
span.1) with a row of^s underneath each.