Appearance
Tree-sitter grammar
Use tree-sitter-coral for native syntax trees, queries, and editor tooling, not as Coral's runtime or semantic parser.
| Concern | Contract |
|---|---|
| Package | tree-sitter-coral@0.2.5 with peer tree-sitter@0.25.1 |
| Build | Native addon compiled from source during install |
| Syntax | nodes/bodies, edges, graph data, positions/pins, constraints, route intent, and comments |
| Not owned | semantic references, capabilities, canonicalization, repair, and rich diagnostics |
Native installation
The package doesn't ship prebuilt binaries. Python is required on every supported native-build platform. Linux/Unix also needs make and a C/C++ toolchain; macOS needs Xcode Command Line Tools; Windows needs Visual Studio C++ build tools.
Before installing with npm 12, approve the native lifecycle scripts in the consumer's root package.json:
json
{
"allowScripts": {
"tree-sitter-coral": true,
"tree-sitter": true
}
}Then install the exact grammar and peer versions verified for Coral 0.2.5:
sh
npm install tree-sitter-coral@0.2.5 tree-sitter@0.25.1Parse Coral
js
import Parser from 'tree-sitter';
import Coral from 'tree-sitter-coral';
const parser = new Parser();
parser.setLanguage(Coral);
const tree = parser.parse('service "API" as api');
if (tree.rootNode.hasError) throw new Error(tree.rootNode.toString());The grammar recognizes the Language 1.0 syntax-tooling subset, including graph headers and structured data; nodes, properties, nesting, positions and pins; edges, labels, ports and styles; required/preferred spatial constraints; route anchors and waypoints; and comments. Use @coral-viz/language to resolve references and produce the runtime GraphIR 2.0 result.