Skip to content

sdif-format/tree-sitter-sdif

Repository files navigation

tree-sitter-sdif

tree-sitter-sdif

Tree-sitter grammar for SDIF syntax highlighting,
editor integrations and incremental parse tooling.

What this is · Quick start · File types · Conformance · Related

Grammar v1 Covers .sdif and .sdif.ai Normative parser: sdif Python



What this is

This package provides a Tree-sitter grammar for SDIF editor tooling and incremental parsing.

It is intentionally tooling-only. The normative parser and canonical AST live in the core sdif-py repository, under src/sdif/. The specification itself is defined in sdif-spec. This grammar is for editors and tooling consumers, not for implementing the SDIF specification.

It does not validate schemas, canonical ordering, semantic relations, hashes or .sdif.ai reversibility. Those checks belong to the core SDIF implementation.

The package registers both sdif and sdif.ai file types so editor integrations can attach the same grammar to canonical source files and compact AI projection surfaces.



Quick start

Install a Tree-sitter CLI compatible with this package and run:

npm install
npm run generate
npm test

The corpus starts at test/corpus/core.txt and covers representative SDIF documents, .sdif.ai compact table syntax and the common patterns defined in the conformance suite.



File types

Extension Format Purpose
.sdif Canonical SDIF Source files, canonical form, hashing and signing surface
.sdif.ai AI projection Token-dense agent exchange; reversible to canonical SDIF

SDIF and .sdif.ai are the agent-facing interchange surfaces. JSON fixtures may exist for equivalence checks, but agents do not need JSON to work with SDIF documents.



Conformance

The grammar must stay aligned with the shared conformance/manifest.sdif fixture suite in the sdif-spec repository. Changes to SDIF syntax that affect the specification should be reflected here.

The corpus in test/corpus/core.txt covers:

  • directives (@sdif, @schema, @include)
  • header fields
  • table declarations with column lists and cell rows
  • relation blocks
  • rules blocks
  • .sdif.ai compact table syntax, including $-suffixed string-preserved columns
  • comments


Highlights

The queries/highlights.scm file maps grammar nodes to standard capture names. It is the starting point for editor syntax highlighting. Integrations using Neovim, Helix, Zed or other Tree-sitter-aware editors can consume it directly.



Ecosystem

This GitHub organization hosts the official SDIF ecosystem: the core format, reference tooling, benchmarks, examples, libraries, and editor extensions.

PYTHON CLIENT & CLI

sdif-py

Specification, parser, canonicalizer, and CLI.
The normative reference implementation.

Explore sdif-py →

SPECIFICATION (SSOT)

sdif-spec

Official format specification, canonicalization rules,
and portable conformance test suite.

View specification →

BENCHMARKS

sdif-benchmarks

Reproducible benchmark datasets and reports comparing SDIF with JSON, YAML, XML, and CSV.

View benchmarks →

RUST IMPLEMENTATION

sdif-rs

Pure Rust parser implementation with a span-annotated AST designed for editor tooling.

Explore sdif-rs →

LANGUAGE SERVER (LSP)

sdif-lsp

LSP language server binary (tower-lsp) providing real-time diagnostics and IDE features.

View sdif-lsp →

EDITOR INTEGRATION

vscode-sdif

VS Code extension client providing syntax highlighting, diagnostics, and LSP configuration.

Open extension →

GRAMMAR FOUNDATION

tree-sitter-sdif

Tree-sitter grammar foundation for syntax highlighting and incremental parsing.

Open grammar →

DOCUMENTATION

sdif-format.github.io

Official documentation website containing specification guides, tutorials, and examples.

Read docs →

ORGANIZATION META

.github

Organization profile, assets, and shared community configuration files.

View profile →


Repository map
Repository Purpose
sdif-py Core Python parser, validator, canonicalizer, and CLI
sdif-spec Official format specification and conformance test suite (SSOT)
sdif-benchmarks Benchmark datasets, reports, and comparison tooling
sdif-rs Rust parser crate with span-annotated AST
sdif-lsp LSP language server binary
tree-sitter-sdif Tree-sitter grammar foundation for syntax highlighting
vscode-sdif VS Code extension client for SDIF
sdif-format.github.io Public documentation website (Docusaurus)
.github Organization profile, assets, and shared GitHub community files

License

MIT. See LICENSE.