Skip to content

Language API ​

Use the language package for Coral runtime parsing, printing, imports, diagnostics, and conservative syntax repair.

Entry pointMain exportsUse it for
@coral-viz/languageparse, print, printWithDiagnostics, importers, diagnostics, repairCoralDslGeneral runtime use
@coral-viz/language/parserparser entry pointsParser-only bundles
@coral-viz/language/printerprinter entry pointsCanonical and diagnostic printing
@coral-viz/language/formatsMermaid, DOT, and PlantUML importersConversion into GraphIR

Install ​

sh
npm install @coral-viz/language@0.2.5 @graph-ir/core@0.2.1

parse returns a graph even when some lines fail, along with diagnostics. Test success before treating it as authored truth. The parser emits GraphIR 2.0; validate the result with the exact core 0.2.1 validator when it crosses an application boundary.

Diagnostics and repair ​

Diagnostics use the closed severities error, warning, and info, stable codes, messages, and optional positions/ranges. printWithDiagnostics reports data it cannot represent instead of silently dropping it.

repairCoralDsl is an explicit, deterministic syntax-repair operation. It byte-preserves parser-valid input, applies only reviewed lexical fixes, records each AppliedFix, and returns unresolved diagnostics. A reduction in syntax errors doesn't prove semantic intent, so show the repaired text for review before replacing authored source.

Parser ownership ​

The portable TypeScript parser is Coral's runtime and semantic parser. The Tree-sitter package is a smaller native grammar for editor syntax tooling. It doesn't replace parse, reference resolution, capability checks, canonicalization, repair, or rich diagnostics.

The published SPEC.md, grammar, diagnostic catalogue, behavior matrices, and conformance corpus are the Language 1.0 contract. GraphIR schema versions and Coral package versions advance independently.