Skip to main content

Module functions

Module functions 

Source
Expand description

Auto-generated module

🤖 Generated with SplitRS

Functions§

binder_error
Convenience: create an InvalidBinder error.
byte_offset_to_line_col
Returns the line and column for a byte offset in source.
classify_error
Classify a ParseError into a human-readable category string.
compact_error_summary
Formats a compact error summary line.
count_by_kind
Return the count of each kind in a ParseErrors collection.
count_by_severity
Counts the number of errors at each severity level.
dedup_by_message
Deduplicates a list of errors by message fingerprint.
dedup_errors
Deduplicate errors by span start position.
duplicate_error
Convenience: create a DuplicateDeclaration error.
earliest_error
Return the error with the earliest position.
error_col
Return the 1-indexed column from a ParseError.
error_col_ext2
Returns the column of a located error.
error_contains
Checks if an error message matches a substring.
error_end
Return the byte end offset from a ParseError.
error_fingerprint
Computes a fingerprint for an error message (for deduplication).
error_kind_name
Return a short category name for a ParseErrorKind.
error_line
Return the 1-indexed line number from a ParseError.
error_line_ext2
Returns the line number of a located error.
error_source_text
Extract the source text covered by the error span.
error_start
Return the byte start offset from a ParseError.
error_to_json
Produce a compact JSON-compatible representation of a ParseError.
errors_have_same_message
Checks if two errors have the same message after normalisation.
errors_to_json
Export all errors in a ParseErrors as a JSON array string.
expand_span
Expand the span of an error by n bytes on both sides (clamped to source bounds).
extract_context
Extract context lines around a given line number from source.
format_annotated_source
Format source text with annotated spans underlined.
format_caret_range
Formats an error range as a caret string (e.g., “ ^^^“).
format_expected
Format a list of expected token descriptions as a human-readable string.
format_gnu_errors
Formats a sequence of errors in GNU style (file:line:col: message).
is_duplicate_error
Return true if the error kind is a duplicate declaration.
is_recoverable
Return true if the error is likely recoverable (parser can continue).
is_syntax_error
Return true if the error kind is an invalid syntax error.
latest_error
Return the error with the latest position.
numbered_error_list
Format a list of errors as a numbered list.
other_error
Convenience: wrap any string into an Other parse error.
parse_location
Parse a source location from a “line:col” string.
partition_by_line
Partitions errors by line number.
pattern_error
Convenience: create an InvalidPattern error.
recovery_hints
Generate recovery hints for common parse errors.
render_diagnostics
Render a collection of diagnostics as a multi-line string.
sort_errors
Sort errors by their span start position.
span_is_empty
Check if an error’s span is empty (zero-length).
span_len
Return the length (in bytes) of the span.
suggest_correction
Suggest a correction for a common typo in keywords.
syntax_error
Convenience: create an InvalidSyntax error at the given location.
total_span
Returns the total byte span covered by a list of errors.
truncate_source
Truncate source text to at most max_len chars, appending … if needed.
underline_span
Return a string that underlines the span within its line.
universe_error
Convenience: create an InvalidUniverse error.
widest_error
Returns the error with the widest span.