Validator

Produce structured diagnostics from a .chart source string.


Functions

validate

validate(source: string): Diagnostic[]

Map a `.chart` source string to a list of structured diagnostics. Returns `[]` for valid input. Does not depend on the LSP — usable in CLI tools, pre-commit hooks, and CI pipelines.


Types

Diagnostic interface

A single parse or semantic issue. `source` is always `'grigson'`.

message: string
range: DiagnosticRange
severity: "error" | "warning"
`'error'` for parse failures; `'warning'` for semantic issues such as beat-count mismatches.
source: "grigson"

DiagnosticRange interface

LSP-compatible source range (0-based line/character). Mirrors the `Range` type from the Language Server Protocol.

end: { character: number; line: number }
start: { character: number; line: number }