Sign in

    moonrockz/gleam-parser/diagnostic does not have a README file

    Diagnostic

    pub(all) struct Diagnostic {
    code : String
    kind : String
    severity : Severity
    title : String
    message : String
    span :
    SrcSpan

    labels : ArrayView[Label]
    text : String
    hint : String?
    } derive(Eq,
    Debug
    )

    A problem found while scanning or parsing, in the Gleam compiler's shape: a title ("Syntax error"), a primary span with its message (the compiler's label text), extra labels, and an optional hint. code is one of codes().

    Diagnostic::is_error

    fn Diagnostic::is_error(self : Diagnostic) -> Bool

    Diagnostic::new

    fn Diagnostic::new(code~ : String, severity~ : Severity, title~ : String, message~ : String, span~ :
    SrcSpan
    , kind? : String, labels? : Array[Label], text? : String, hint? : String?) -> Diagnostic

    test {
    let d = @diagnostic.Diagnostic::new(
    code="GL-SCAN-001",
    severity=Error,
    title="Syntax error",
    message="I don't know what this character means",
    span=@span.SrcSpan::new(2, 3),
    )
    debug_inspect(d.is_error(), content="true")
    debug_inspect(d.labels.length(), content="0")
    }

    Label

    pub(all) struct Label {
    span :
    SrcSpan

    text : String
    } derive(Eq,
    Debug
    )

    A span with the text the compiler shows under it.

    Severity

    pub(all) enum Severity {
    Error
    Warning
    } derive(Eq, Hash,
    Debug
    )

    How serious a diagnostic is. A file with an Error is rejected; a Warning does not stop parsing.

    codes

    fn codes() -> ArrayView[String]

    Every diagnostic code, in table order.

    description

    fn description(code : String) -> String?

    The one-line description of a code, or None for an unknown code.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io