lang F0.1: extractContext utility for diagnostic renderer

Adds LineInfo, ContextLines, and extractContext(allocator, source, span) to
errors.zig — a pure utility that returns the source lines covered by a span
plus columns for caret rendering. Prereq for F0.2's new render path which
will produce Rust-style multi-line diagnostics with code excerpts.

8 unit tests cover the boundary cases: single-line span, multi-line spans
(1 and 2 newlines crossed), span on an empty line, span at end-of-file
without trailing newline, empty source, and offsets beyond source.len
(clamping).

No render surface change yet; F0.2 wires this into a new render mode kept
behind a RenderStyle flag so old gcc-style output remains available during
the transition.
This commit is contained in:
agra
2026-05-28 19:37:00 +03:00
parent 29bd182f3f
commit e347f59e50
3 changed files with 176 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ pub const types = @import("types.zig");
pub const target = @import("target.zig");
pub const builtins = @import("builtins.zig");
pub const errors = @import("errors.zig");
pub const errors_tests = @import("errors.test.zig");
pub const sema = @import("sema.zig");
pub const imports = @import("imports.zig");
pub const core = @import("core.zig");