Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Syntax.Diagnostic

The typed vocabulary of the prism-syntax-diagnostics-v1 artifact.

One document per source file: the embedded source identity and every syntax-boundary diagnostic the lexer or parser produced for it, in source order. An accepted file carries the empty list, so acceptance and refusal share one shape. expected and related are reserved surfaces: always present, possibly empty, so a reader written today survives their arrival.

Types

DiagPhase

type DiagPhase = DPLex | DPParse

The phase that raised a diagnostic.

Diagnostic

type Diagnostic = Diagnostic {
  code: String,
  phase: DiagPhase,
  span: Span,
  message: String,
  expected: List(String),
  related: List(Span)
}

One diagnostic: the stable append-only code, the raising phase, the primary half-open byte span (a lex fault is a caret, lo == hi), the rendered message, the parser’s canonical expectation set when it has one, and related spans.

DiagnosticsDoc

type DiagnosticsDoc = DiagnosticsDoc {
  schema: String,
  compiler: String,
  source: SourceFile,
  diagnostics: List(Diagnostic)
}

A decoded diagnostics document: the envelope identity, the embedded source every span indexes into, and the diagnostics in source order.

Functions and Values

diagnostics_schema

diagnostics_schema : () -> String

The schema tag this vocabulary decodes.

doc_accepted

doc_accepted : (Syntax.Diagnostic.DiagnosticsDoc) -> Bool

Whether the document accepted its source (no diagnostics).