Source: src/error/error.lx
Compiler error reporting.
Collects diagnostics into a bounded list and renders them with source excerpts, line numbers, and caret indicators before the compiler aborts.
Describes one compiler error with its location, source line, and notes.
| Field | Type | Description |
|---|---|---|
error_type |
*byte | |
file_path |
*byte | |
message |
*byte | |
line |
i64 | |
col |
i64 | |
line_text |
*byte | |
token_length |
i64 | |
label |
*byte | |
note |
*byte | |
help |
*byte |
Emits the ANSI reset escape sequence.
c_reset -> fn(
) void
Emits the bold-red escape sequence (error labels).
c_bold_red -> fn(
) void
Emits the bold-white escape sequence (messages).
c_bold_white -> fn(
) void
Emits the bold-blue escape sequence (file locations).
c_bold_blue -> fn(
) void
Emits the bold-yellow escape sequence (caret indicators).
c_bold_yellow -> fn(
) void
Emits the bold-cyan escape sequence (notes).
c_bold_cyan -> fn(
) void
Emits the bold-green escape sequence (help text).
c_bold_green -> fn(
) void
Emits the plain blue escape sequence.
c_blue -> fn(
) void
Emits the gray (bright black) escape sequence.
c_gray -> fn(
) void
Queues an error if the list is not full.
pub error_add -> fn(
err: ErrorInformation
) void
Queues an error, marking message as consumed so the static analyzer
does not report a owned message as leaked.
pub #takes_ownership
error_add_msg -> fn(
message: *byte,
err: ErrorInformation
) void
Clears all queued errors.
pub error_clear -> fn(
) void
Returns the number of queued errors.
pub error_get_count -> fn(
) i64
Reduces the queued error count to at most n.
pub error_truncate -> fn(
n: i64
) void
Returns 1 if any errors are queued, else 0.
pub error_has_errors -> fn(
) i64
Returns a pointer to the queued error at index, or NULL when the index
is out of bounds.
pub error_get_at_index -> fn(
index: i64
) *ErrorInformation
Reconstructs the source text of target_line from its tokens.
Restores inter-token whitespace, wraps string tokens in quotes, and
re-emits /// / //! doc-comment prefixes so the line can be shown
verbatim in diagnostics. Returns an allocated string (an allocated empty
string when the line is out of range or tokens is NULL).
pub #returns_ownership
generate_line -> fn(
tokens: *TOK::Token,
token_count: i64,
target_line: i64
) *byte
Returns the number of digits in line (used for gutter alignment).
get_line_width -> fn(
line: i64
) i64
Returns the widest line number among the queued errors.
get_max_line_width -> fn(
) i64
Prints spaces so current_line aligns to max_width.
print_line_padding -> fn(
current_line: i64,
max_width: i64
) void
Prints the blank gutter with its | separator.
print_gutter -> fn(
max_width: i64
) void
Prints one source line prefixed by its line number in the gutter.
print_source_line -> fn(
line: i64,
text: *byte,
max_width: i64
) void
Prints the ^ caret indicator under a source position, plus its label.
print_indicator -> fn(
col: i64,
length: i64,
max_width: i64,
label: *byte
) void
Prints all queued errors, each with location, source excerpt, and any note/help lines.
pub error_report -> fn(
) i64
Returns:
1 if errors are queued, 0 when the queue is empty.
MAX_ERRORS: i64 (const) — Maximum number of errors kept before the list silently stops growing.error_list: [ErrorInformation; 256] (let) — Fixed-size storage for queued errors.error_count: i64 (let) — Number of errors currently queued inerror_list.error_silent: bool (let) — When true,error_reportrecords no terminal output (for LSP analysis).