Appearance
Language API
Use the language package for Coral runtime parsing, printing, imports, diagnostics, and conservative syntax repair.
| Entry point | Main exports | Use it for |
|---|---|---|
@coral-viz/language | parse, print, printWithDiagnostics, importers, diagnostics, repairCoralDsl | General runtime use |
@coral-viz/language/parser | parser entry points | Parser-only bundles |
@coral-viz/language/printer | printer entry points | Canonical and diagnostic printing |
@coral-viz/language/formats | Mermaid, DOT, and PlantUML importers | Conversion into GraphIR |
Install
sh
npm install @coral-viz/language@0.2.5 @graph-ir/core@0.2.1parse 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.